Skip to content
Merged
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
4 changes: 2 additions & 2 deletions di/torq/proc/chainedtp/chainedtp.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ by tick or in batches.
| Key | Default |
|---|---|
| `tickerplantname` | `` `tickerplant1 `` — procname(s) of the upstream |
| `pubinterval` | `0D00:00:00` — tick by tick; above 0, batches published on a timer |
| `pubinterval` | `0D00:00:00` — tick by tick; above 0, batches published on a timer. Also a `"0D00:00:01"` string or seconds |
| `tpconnsleep` / `tpcheckcycles` | `10` / `0W` — seconds between, and number of, upstream checks |
| `createlogfile` / `logdir` / `clearlogonsubscription` | `0b` / `` `:tplogs `` / `0b` — log file `<logdir>/<procname>_<date>` |
| `createlogfile` / `logdir` / `clearlogonsubscription` | `0b` / `` `:tplogs `` / `0b` — log file `<logdir>/<procname>_<date>`; `logdir` may be a path string |
| `subscribeto` / `subscribesyms` | `` ` `` / `` ` `` — all tables, all syms |
| `replay` / `schema` | `0b` / `1b` |
| `connections` / `startup` | `` `tickerplant `` / `1b` |
Expand Down
5 changes: 5 additions & 0 deletions di/torq/proc/chainedtp/chainedtp.q
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/ di.torq.proc.chainedtp - chained tickerplant

/ a timespan, a "0D00:00:01" string or a number of seconds (TOML has no timespan type)
Comment thread
alowrydi marked this conversation as resolved.
Resolved
totimespan:{[x] $[-16h=type x;x;10h=abs type x;"N"$(),x;-11h=type x;"N"$string x;type[x] in -5 -6 -7h;0D00:00:01*x;0Nn]};

init:{[config;deps]
if[not `log in key deps;'"di.torq.proc.chainedtp: log dependency is required - see di.util.log"];
if[not `timer in key deps;'"di.torq.proc.chainedtp: timer dependency is required - see di.timer"];
Expand All @@ -10,6 +13,8 @@ init:{[config;deps]
(deps[`handlers]`register)[`.z.pc;`;`stpps;0j;.stpps.closesub];
(use`di.subscriptions)[`init][config;deps];
{[config;k] if[k in key config;set[` sv `.ctp,k;config k]]}[config] each `tickerplantname`pubinterval`tpconnsleep`createlogfile`logdir`subscribeto`subscribesyms`replay`schema`clearlogonsubscription`tpcheckcycles;
.ctp.pubinterval:totimespan .ctp.pubinterval;
Comment thread
alowrydi marked this conversation as resolved.
Resolved
if[10h=type .ctp.logdir;.ctp.logdir:hsym`$.ctp.logdir];
if[0<>(`long$.ctp.pubinterval) mod 1000000000;'"di.torq.proc.chainedtp: pubinterval must be a whole number of seconds"];
(deps[`handlers]`register)[`.z.pc;`;`chainedtp;0j;{[y] if[.ctp.tph=y;.z.m.log[`error][`.z.pc;"lost connection to tickerplant : ",string .ctp.tickerplantname];exit 0]}];
.ctp.upd:$[.ctp.createlogfile;
Expand Down
4 changes: 3 additions & 1 deletion di/torq/proc/chainedtp/test.csv
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ fail,0,0,q,"ctp.init[cfg[],enlist[`pubinterval]!enlist 0D00:00:00.500;deps[]]",1
fail,0,0,q,"ctp.init[cfg[],enlist[`pubinterval]!enlist 0D00:00:01.500;deps[]]",1,,a fractional-second pubinterval must error

comment,,,,,,,init - connect and subscribe
run,0,0,q,ctp.init[cfg[];deps[]],1,,init
run,0,0,q,"ctp.init[cfg[],`pubinterval`logdir!(""0D00:00:00"";""tplogs"");deps[]]",1,,init with toml-style pubinterval and logdir strings
true,0,0,q,0D~.ctp.pubinterval,1,,a pubinterval string becomes a timespan
true,0,0,q,`:tplogs~.ctp.logdir,1,,a logdir string becomes a file symbol
true,0,0,q,".ctp.tph=first exec w from .servers.SERVERS where procname=`tickerplant1",1,,tph is the upstream handle
true,0,0,q,`trade in tables[],1,,upstream schema defined at root
true,0,0,q,.u.d~D,1,,date taken from the .u.subdetails reply
Expand Down
6 changes: 3 additions & 3 deletions di/torq/servers/servers.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ supplies the discovery process's values.
| `discoveryregister` | `.servers.DISCOVERYREGISTER` | `1b` |
| `connectionsfromdiscovery` | `.servers.CONNECTIONSFROMDISCOVERY` | `1b` |
| `subscribetodiscovery` | `.servers.SUBSCRIBETODISCOVERY` | `1b` |
| `discoveryretry` | `.servers.DISCOVERYRETRY` | `0D00:05` |
| `discoveryretry` | `.servers.DISCOVERYRETRY` | `0D00:05`; string or seconds allowed |
| `tracknontorqprocess` | `.servers.TRACKNONTORQPROCESS` | `0b` |
| `hopentimeout` | `.servers.HOPENTIMEOUT` | `2000` |
| `retry` | `.servers.RETRY` | `0D00:05` |
| `retry` | `.servers.RETRY` | `0D00:05`; string or seconds allowed |
| `retain` | `.servers.RETAIN` | `` `long$0D00:30 `` |
| `autoclean` | `.servers.AUTOCLEAN` | `0b` |
| `debug` | `.servers.DEBUG` | `1b` |
Expand Down Expand Up @@ -153,7 +153,7 @@ peers. Peers call discovery's root `register` (as `` `..register ``) and `getser

## Tests

`test.q` + `test.csv` (54 checks) spawn real q peers. They cover:
`test.q` + `test.csv` (56 checks) spawn real q peers. They cover:
- init validation, wiring and idempotency;
- `startup` against a live and a dead peer (discovery off);
- `gethandlebytype`, and retry recovering an ungraceful kill;
Expand Down
5 changes: 5 additions & 0 deletions di/torq/servers/servers.q
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ raiseerror:{[ctx;msg]
'"di.torq.servers: ",string[ctx],": ",msg;
};

/ a timespan, a "0D00:00:10" string or a number of seconds (TOML has no timespan type)
totimespan:{[x] $[-16h=type x;x;10h=abs type x;"N"$(),x;-11h=type x;"N"$string x;type[x] in -5 -6 -7h;0D00:00:01*x;0Nn]};

init:{[deps]
/ wire deps and config, publish root names, register .z.pc and retry timers once
if[99h<>type deps;
Expand Down Expand Up @@ -61,6 +64,8 @@ init:{[deps]
@[value;`.servers.SERVERS;{set[`.servers.SERVERS;([]procname:`symbol$();proctype:`symbol$();hpup:`symbol$();w:`int$();hits:`int$();startp:`timestamp$();lastp:`timestamp$();endp:`timestamp$();attributes:())]}];
/ config
{[deps;k] set[first .z.m.settings k;$[k in key deps;deps k;last .z.m.settings k]]}[deps] each key .z.m.settings;
.servers.RETRY:totimespan .servers.RETRY;
.servers.DISCOVERYRETRY:totimespan .servers.DISCOVERYRETRY;
set[`.servers.NONTORQPROCESSFILE;$[`nontorqprocessfile in key deps;hsym deps`nontorqprocessfile;hsym `$("/" sv -1_"/" vs .z.m.processcsv),"/nontorqprocess.csv"]];
/ live-handle checks
set[`.dotz.liveh;{x in key .z.W}];
Expand Down
3 changes: 3 additions & 0 deletions di/torq/servers/test.csv
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ run,0,0,q,svc.startup[svrdeps[`tpproc]],1,1,startup while discovery is down - th
true,0,0,q,0=count svc.getservers[`discovery],1,1,discovery is not live after startup
run,0,0,q,spawndisc[],1,1,bring up the tpproc peer then discovery
true,0,0,q,svc.waitfortype[`tpproc;3000;200],1,1,waitfortype reaches discovery and connects to the tpproc it names
comment,,,,,,,retry periods from toml
run,0,0,q,"svc.init[svrdeps[`otherproc],`retry`discoveryretry!(""0D00:00:10"";10)]",1,1,retry as a string and discoveryretry as seconds
true,0,0,q,"(0D00:00:10;0D00:00:10)~(.servers.RETRY;.servers.DISCOVERYRETRY)",1,1,both become timespans
comment,,,,,,,input validation + getapimeta
fail,0,0,q,"svc.getservers[""nosuch""]",1,1,getservers rejects a non-symbol proctype
fail,0,0,q,"svc.gethandlebytype[`hdb;""any""]",1,1,gethandlebytype rejects a non-symbol selection
Expand Down