-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gh-10 Add build script for standalone versions
* Add build script to build standalone versions of ws-client.q & ws-server.q * Update README to include details of standalone versions * Incorporate necessary reQ functions into ws-client, if reQ not independently loaded * Update build number in Conda pkg configs * Make ws-handler capable to be loaded multiple times without side-effects Resolves gh-10
- Loading branch information
1 parent
e324fc5
commit 26c479d
Showing
7 changed files
with
90 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,6 @@ | |
|
||
A simple set of modules for using WebSockets in KDB+/q | ||
|
||
`ws-handler` is a generic wrapper for `.z.ws` in order to allow different handlers to be defined depending on wether the q session is a client or server for the present connection. | ||
|
||
`ws-client` provides function `.ws.open` to open a WebSocket as a client, allowing definition of a per- | ||
socket callback function, tracked in a keyed table `.ws.w` | ||
|
||
|
@@ -12,9 +10,37 @@ implementation in the form of `wschaintick.q`, a chained tickerplant which | |
subscribes to a regular kdb+tick TP & republishes received records via | ||
WebSockets. [See below](#ws-handler--wschaintickq) for more details. | ||
|
||
## Installation | ||
`ws-handler` is a generic wrapper for `.z.ws` in order to allow different handlers to be defined depending | ||
on wether the q session is a client or server for the present connection. Typically it shouldn't be loaded | ||
directly but will be loaded as a dependency of the client/server libs. | ||
|
||
## Setup | ||
|
||
The simplest way for most people to setup will be using the standalone scripts from the latest release in the | ||
repo's [Releases](https://github.com/jonathonmcmurray/ws.q/releases) tab. These scripts can be loaded directly | ||
into a q session & have no dependencies e.g. (with client library) | ||
|
||
``` | ||
$ q | ||
KDB+ 4.0 2020.05.04 Copyright (C) 1993-2020 Kx Systems | ||
l64/ 12(16)core 16296MB jonny desktop-c4h2kis 127.0.1.1 EXPIRE 2021.06.05 [email protected] KOD #4171328 | ||
q)\l ws-client_0.2.0.q | ||
q).echo.upd:show | ||
q).echo.h:.ws.open["wss://echo.websocket.org";`.echo.upd] | ||
q).echo.h "hello world" | ||
q)"hello world" | ||
``` | ||
|
||
Note that other examples in this readme use e.g. `.utl.require"ws-client"` to load lib instead of `\l` - you can simply replace | ||
with the relevant `\l` command if using the standalone scripts. | ||
|
||
The simplest way to install the modules is via Anaconda. Assuming an Anaconda distribution is installed (e.g. [miniconda](https://conda.io/en/latest/miniconda.html)), installation is as follows: | ||
It should be possible to load both `ws-client_*.q` and `ws-server_*.q` in the same q process without conflict if a single | ||
process needs to act as both a server & client. | ||
|
||
## Installation via Anaconda | ||
|
||
It is also possible to install the modules via Anaconda. Assuming an Anaconda distribution is installed (e.g. [miniconda](https://conda.io/en/latest/miniconda.html)), installation is as follows: | ||
|
||
```bash | ||
$ conda install -c jmcmurray ws-client ws-server | ||
|
@@ -60,7 +86,7 @@ l64/ 8()core 16048MB jmcmurray homer.aquaq.co.uk 127.0.1.1 EXPIRE 2018.06.30 Aqu | |
q).utl.require"ws-client" | ||
q).echo.upd:show | ||
q).echo.h:.ws.open["ws://demos.kaazing.com/echo";`.echo.upd] | ||
q).echo.h:.ws.open["wss://echo.websocket.org";`.echo.upd] | ||
q).echo.h "hi" | ||
q)"hi" | ||
.echo.h "kdb4life" | ||
|
@@ -131,6 +157,10 @@ socket. This object contains three keys, `type`, `tables` and `syms`. `type` is | |
while `tables` & `syms` are lists of tables & syms to subscribe to. Similar to `u.q`, | ||
an empty list (including leaving out the key) subscribes to everything available. | ||
|
||
Note: if using the standalone version of `ws-server_*.q` from [Releases](https://github.com/jonathonmcmurray/ws.q/releases) | ||
page, please use `wschaintick.q` from there as well (version from main repo uses | ||
qutil to load `ws-server`). | ||
|
||
### q client via `ws-client` | ||
|
||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
# Script to build standalone release versions of ws-client.q and ws-server.q | ||
|
||
RELEASE=${1} | ||
|
||
cat ws-handler/ws-handler.q ws-client/ws.q > ws-client_${RELEASE}.q | ||
cat ws-handler/ws-handler.q ws-server/wsu.q > ws-server_${RELEASE}.q | ||
sed "s/.utl.require\"ws-server\"/\\\\l ws-server_${RELEASE}.q/g" wschaintick.q > wschaintick_${RELEASE}.q |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package: | ||
name: ws-client | ||
version: 0.1.0 | ||
version: 0.2.0 | ||
|
||
build: | ||
number: 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package: | ||
name: ws-handler | ||
version: 0.1.0 | ||
version: 0.2.0 | ||
|
||
build: | ||
number: 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package: | ||
name: ws-server | ||
version: 0.1.0 | ||
version: 0.2.0 | ||
|
||
build: | ||
number: 0 | ||
|