Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .log

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this file

Binary file not shown.
27 changes: 0 additions & 27 deletions di/async/test.csv

This file was deleted.

14 changes: 7 additions & 7 deletions di/async/async.md → di/asyncutil/asyncutil.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,28 @@ If either of these are carried out via asynchronous broadcast, the request will

Note, in each of the examples below handles is a list of two handles to different server processes

##### async.deferred
##### asyncutil.deferred
Can be used to make deferred synchronous calls via asynchronous broadcast. It will send the query down each of the handles, then block and wait on the handles
The result set is of the form (successvector each handle; result vector)
Note, that if there is an issue with any of the handles, the query won't be sent down any handle

```q
// async.deferred[handles;query]
q)async.deferred[handles;"2+2"]
// asyncutil.deferred[handles;query]
q)asyncutil.deferred[handles;"2+2"]
1 1
4 4
```

##### async.postback
##### asyncutil.postback
Can be used to make asynchronous postback calls via asynchronous broadcast.
Wrap the supplied query in a postback function
Don't block the handle when waiting
Success vector is returned that it has been sent correctly
The result is then returned once executed by the server, although it is not wrapped in the status
Similar to async.deferred, if there is an issue with any of the handles, the query won't be sent down any handle
Similar to asyncutil.deferred, if there is an issue with any of the handles, the query won't be sent down any handle
```q
// async.postback[handles;query;postback]
q)async.postback[handles;"2+2";{show x}]
// asyncutil.postback[handles;query;postback]
q)asyncutil.postback[handles;"2+2";{show x}]
11b
4
4
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion di/async/init.q → di/asyncutil/init.q
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
\l ::async.q
\l ::asyncutil.q

export:([deferred;postback])
27 changes: 27 additions & 0 deletions di/asyncutil/test.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
action,ms,bytes,lang,code,repeat,minver,comment
before,0,0,q,asyncutil:use`di.asyncutil,1,1,load module into session

comment,,,,,,,Testing asyncutil.deferred
run,0,0,q,.test.bdefres1:asyncutil.deferred[h;({x+1};1)],1,,testing asyncutil.deferred call that should execute on both servers
true,0,0,q,.test.bdefres1~((1b;1b);(2;2)),1,,successful asyncutil.deferred call with expected result
run,0,0,q,.test.bdefres2:asyncutil.deferred[h;({x+`a};1)],1,,testing asyncutil.deferred call that should fail
true,0,0,q,not any .test.bdefres2[0;],1,,asyncutil.deferred call failed on both servers with expected result
run,0,0,q,.test.bdefres3:asyncutil.deferred[h;(`f;1)],1,,testing asyncutil.deferred call that should fail on one server
true,0,0,q,10b ~ .test.bdefres3[0;],1,,asyncutil.deferred call failed on one server with expected result
run,0,0,q,.test.bdefres3:asyncutil.deferred[h;(`f;1)],1,,testing asyncutil.deferred call that should fail on one server
true,0,0,q,10b ~ .test.bdefres3[0;],1,,asyncutil.deferred call failed on one server with expected result

comment,,,,,,,Testing asyncutil.postback
run,0,0,q,".test.bpbrestab:([]handle:();time:();result:())",1,,define table .test.bpbrestab to store results from asyncutil.postback
run,0,0,q,".test.storeresult:{`.test.bpbrestab upsert (.z.w;.z.t;enlist x)}",1,,define a function .test.storeresult to store the posted back results in .test.bpbrestab
run,0,0,q,asyncutil.postback[h;({x+1};2);`.test.storeresult],1,,testing asyncutil.postback that should execute on both servers
run,0,0,q,@[;"";()] each h,1,,wait for server response
true,0,0,q,(enlist 3;enlist 3) ~ -2#exec result from .test.bpbrestab,1,,successful asyncutil.postback with expected result
run,0,0,q,asyncutil.postback[h;({x+`a};2);`.test.storeresult],1,,testing asyncutil.postback call that should fail on both servers
run,0,0,q,@[;"";()] each h,1,,wait for server response
true,0,0,q,all all (exec result from -2#.test.bpbrestab) like\: "error*",1,,asyncutil.postback call failed on both servers with expected result
run,0,0,q,asyncutil.postback[h;(`f;1);`.test.storeresult],1,,testing asyncutil.postback call that should fail on one server
run,0,0,q,@[;"";()] each h,1,,wait for server response
true,0,0,q,(enlist 2;enlist "error: server fail: f") ~ exec result from -2#.test.bpbrestab,1,,asyncutil.postback call failed on one server with expected result

run,0,0,q,@[;"exit 0";()] each neg h,,1,,closing remaining server process
Binary file added main.zip

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this file

Binary file not shown.