

pmallon
Forum Replies Created
-
Hi Mannix,
Try >> new.log to append to the file.
Thanks,
Patrick
-
pmallon
MemberMarch 24, 2022 at 12:00 am in reply to: How to know if sym file for new update after .Q.enHi,
You should be able to check by the timestamp on the sym file:
q).z.p 2022.03.24D13:36:35.138809000 q)t:([]s:`a`b`c) q).Q.en[`:.]t s - a b c q)ls -lrt sym "-rw-r--r-- 1 pat pat 14 Mar 24 13:36 sym" q)/ add a sym to t q)t:([]s:`a`b`c`d) q).z.p 2022.03.24D13:37:20.140371000 q).Q.en[`:.]t s - a b c d q)ls -lrt sym "-rw-r--r-- 1 pat pat 16 Mar 24 13:37 sym"
If that doesn’t work for you, maybe a simply modified version like:
q)modQen:{s:sym;.Q.en[x]y;sym except s} q)t:([]s:`a`b`c`d`e) / add e to t q)modQen[`:.;t] ,`e q)/ run again to show no update to sym, .i.e empty list returned q)modQen[`:.;t] `symbol$()
Thanks,
Patrick
-
pmallon
MemberMarch 17, 2022 at 12:00 am in reply to: Can I apply a timeout for a spectific query or client request?Hi,
Maybe something like this on the process servicing the queries:
funcTimeouts:`func1``func2`func3!60 5 10; .z.pg:{ system T , string funcTimeouts x 0; value x }
Not complete above as need to consider funcs not in the dictionary and possibly resetting T after. Also, above assumes you call a function over the handle in list format.
Adding logging to .z.pg might help you identify the issue too.
Let me know if this helps.
Patrick
-
Hi,
1-3) Correct.
4) yes this is a date, you will notice end is called from endofday function in tick.q, which is called when the date rolls, checked on the timer.
endofday:{end d;d+:1;if[l;hclose l;l::0(`.u.ld;d)]};
Where d is the current date the tp is running.
.u.end will be an EOD function on the subscriber, commonly an RDB an example below from r.q:
/ end of day: save, clear, hdb reload .u.end:{t:tables`.;t@:where `g=attr each t@:`sym;.Q.hdpf[`$":",.u.x 1;`:.;x;`sym];@[;`sym;`g#] each t;}
Hope that helps.
Patrick
-
pmallon
MemberMarch 17, 2022 at 12:00 am in reply to: Why do we use sel[x] here in u.q, could we not have just used x?Hi,
The sel[x]w 1 , call is the same as sel[x;w 1]. So, y =w 1, which will be a list of symbols or ` if no filtering on syms is to be applied.
Then within sel function, filtering is applied if y is not equal to ` with the select from x where sym in y.Omitting sel from the pub function would remove this functionality to subscribe to a subset of syms.
Let me know if this helps or not.
Patrick
-
pmallon
MemberMarch 13, 2022 at 12:00 am in reply to: What is the purpose of the underscore in this line of u.qHi,
it is drop in place to modify the dictionary w of table subscriptions. It is checking the list of subs for table x, for handle y, if there is an item its dropped from the list and w[x] is updated.
section at the bottom here on drop in place:
Drop in place
Assign through Drop to delete in place.
q)show d:`a`b`c`x!(1;2 3;4;5) a| 1 b| 2 3 c| 4 x| 5 q)d _:`x q)d a| 1 b| 2 3 c| 4
Hope that helps, if not let me know.
-
Yea Ok, that’s a fair point. In that case hopefully the 2nd point above helps get you started… if not let me know.
thanks
-
Hi,
Is there a specific reason for server>client?
I have tried to cover both below, hopefully it is at least a starter for you and helps..
q)/server process q)p 50001 q)/ heartbeat table to log hbs q)heartbeat:([host:`$();port:`long$()];hdl:`int$();lastPing:`timestamp$();pings:`long$()) q)/function to log hearbeat on server q)registerHeartBeat:{[hst;prt] `heartbeat upsert (hst;prt;.z.w;.z.p;)1+0^first exec pings from heartbeat where host=hst,port=prt }
q)/client process q)p 50000 q)/ hdl to server q).R.Server:hopen `::50001 q)/ send heartbeat from client to server q)sendHeartBeat:{ .R.Server (`registerHeartBeat;.z.h;system "p")} q)/ call send a heart beat from client to server q)sendHeartBeat[] / this could be on a timer `heartbeat // check on the server q)heartbeat host port | hdl lastPing pings ---------------------| --------------------------------------- desktop 50000| 9 2022.03.04D12:31:48.583133000 1
/ initiating from server side / have each client process register with the server on startup (for this I have just manually called sendHeartBeat from client) / to add hdls to heartbeat table q)/ callback type idea to initiate a registerHeartBeat call q)reportToServer:{ .z.w (`registerHeartBeat;.z.h;system "p")} q)/ this function on server would request a heart beat from each hdl in the heartbeat table q)getHeartBeatFromServer:{ (exec distinct hdl from heartbeat)@:(reportToServer;`)} q)/ call above function, which could be on a timer q)getHeartBeatFromServer[] ,`heartbeat q)heartbeat host port | hdl lastPing pings ---------------------| --------------------------------------- desktop 50000| 9 2022.03.04D12:33:28.583133000 2
Thanks
-
Hi,
I think you might want to use .z.ps/.z.pg for this, does the below do what you want?
q)admin:([]query:();time:`timestamp$();user:`$();handle:`int$()) q).z.ps:{`admin upsert enlist ( x 0;.z.p;.z.u;.z.w);value x;} q).z.pg:{`admin upsert enlist ( x 0;.z.p;.z.u;.z.w);value x} q)0 (+;1;2) / run on local p q)admin query time user handle -------------------------------------------------- + 2022.03.01D13:14:16.858901000 pm 0