Skip to content

Commit

Permalink
add simple IPC client and server examples
Browse files Browse the repository at this point in the history
  • Loading branch information
briangu committed Dec 21, 2023
1 parent 8e2ea16 commit c1121c1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vscode/
.DS_Store

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
19 changes: 19 additions & 0 deletions examples/ipc/simple_client.kg
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
:" create the IPC server at port 8888 "
cli::.cli(8888)

:" get a reference to the server square function "
sq::cli(:square)

:" add the square function so it can be called by the client "
.p("calling square function")
.p(sq(5))

:" get the dictionary reference to the server so we can call the square function directly "
.p("getting dictionary client")
d::.clid(cli)
.p("retrieving square function from dictionary")
sq2::d?:square
.p("calling square function")
.p(sq2(5))

.clic(cli)
6 changes: 6 additions & 0 deletions examples/ipc/simple_server.kg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:" create the IPC server at port 8888 "
.srv(8888)

:" add the square function so it can be called by the client "
square::{x*x}

2 changes: 1 addition & 1 deletion examples/stocks/alpaca/update_data.kg
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ args:::{};{args,x,,y}'keys
tc::.pyc(TradingClient;[];args)
account::.pyc(tc,"get_account";[];:{})

.d("cash: ");.p(.pyc(account,"cash";[];:{}))
.d("cash: ");.p(.pya(account;"cash"))

dc::.pyc(StockHistoricalDataClient;[];keys)
tr::.pyc(StockLatestTradeRequest;[];:{["symbol_or_symbols" ["MSFT"]]})
Expand Down

0 comments on commit c1121c1

Please sign in to comment.