If I want to publish to table, once I load in u.q in order to subscribe to a table, I need to do define upd correct?
I have defined upd as upd:{[tabname;tabdata] tabname upsert tabdata} but when I call .u.pub nothing gets inserted. Am I missing something here?
Right, I have that example working, but I cant figure out why when I do it in my environment upd wont get called. Seems like I am doing the same as that example.
- load u.q
- create table
- call .u.init
- define upd
- call .u.pub
I have tried defining upd to show and to insert and neither seem to work.
Did you connect to your publisher process from your subscriber process?
Did you define upd in your subscriber process?
Did you called .. from your subscriber process?
h(`.u.sub;`;`)
On Thursday, January 15, 2015 at 2:21:34 PM UTC, Roni Hoffman wrote:
Right, I have that example working, but I cant figure out why when I do it in my environment upd wont get called. Seems like I am doing the same as that example.
- load u.q
- create table
- call .u.init
- define upd
- call .u.pub
I have tried defining upd to show and to insert and neither seem to work.
Oh I see, so pub only works if there are subscribers? I was wondering if I could use pub to insert and then subscribe when I need to.
The publisher and subscriber in this example are two different processes.
In order to get the published data to a subscriber, the subscriber will have to hopen the publisher process port and then send the `.u.sub message shown below.
h:hopen 1234 // publisher port
h(`.u.sub;`;`)
Here’s a breakdown of this call:
h is handle to publisher process
1st arg is calling .u.sub on pub process. So the publisher knows where to send the data.
2nd arg is the table you want. ` is for all tables (symbol)
3rd is the sym from that table you want. ` is for all syms (symbol)
After this, when .u.pub is called on the publisher process it will send the message to the subscriber process.
Shown here in .u.pub
(neg first w)(
upd;t;x)`
The subscriber process then calls the upd function with two arguments, table name (symbol) and row data.
Oh I see, that makes perfect sense, thanks so much.