From 2c2350c7a1b1c463939026d4b6fe1766d6fbef90 Mon Sep 17 00:00:00 2001 From: alowrydi Date: Tue, 29 Sep 2026 11:11:24 +0100 Subject: [PATCH 1/2] Accept TOML-style retry and pubinterval settings di.torq.servers converts retry and discoveryretry, and di.torq.proc.chainedtp converts pubinterval, from a timespan, a "0D00:00:10" string or a number of seconds; chainedtp also takes logdir as a path string. TOML has no timespan type, so these settings can now live in .toml files. New test rows fail on the previous code. Co-Authored-By: Claude Opus 5.5 --- di/torq/proc/chainedtp/chainedtp.md | 4 ++-- di/torq/proc/chainedtp/chainedtp.q | 5 +++++ di/torq/proc/chainedtp/test.csv | 4 +++- di/torq/servers/servers.md | 6 +++--- di/torq/servers/servers.q | 5 +++++ di/torq/servers/test.csv | 3 +++ 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/di/torq/proc/chainedtp/chainedtp.md b/di/torq/proc/chainedtp/chainedtp.md index 8902f215..8721b4ff 100644 --- a/di/torq/proc/chainedtp/chainedtp.md +++ b/di/torq/proc/chainedtp/chainedtp.md @@ -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 `/_` | +| `createlogfile` / `logdir` / `clearlogonsubscription` | `0b` / `` `:tplogs `` / `0b` — log file `/_`; `logdir` may be a path string | | `subscribeto` / `subscribesyms` | `` ` `` / `` ` `` — all tables, all syms | | `replay` / `schema` | `0b` / `1b` | | `connections` / `startup` | `` `tickerplant `` / `1b` | diff --git a/di/torq/proc/chainedtp/chainedtp.q b/di/torq/proc/chainedtp/chainedtp.q index fce9f4fb..2103f6bc 100644 --- a/di/torq/proc/chainedtp/chainedtp.q +++ b/di/torq/proc/chainedtp/chainedtp.q @@ -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) +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"]; @@ -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; + 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; diff --git a/di/torq/proc/chainedtp/test.csv b/di/torq/proc/chainedtp/test.csv index 930ec5ac..1b2cf237 100644 --- a/di/torq/proc/chainedtp/test.csv +++ b/di/torq/proc/chainedtp/test.csv @@ -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 diff --git a/di/torq/servers/servers.md b/di/torq/servers/servers.md index 9400ddc3..0b33b6be 100644 --- a/di/torq/servers/servers.md +++ b/di/torq/servers/servers.md @@ -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`; also a `"0D00:00:10"` string or seconds | | `tracknontorqprocess` | `.servers.TRACKNONTORQPROCESS` | `0b` | | `hopentimeout` | `.servers.HOPENTIMEOUT` | `2000` | -| `retry` | `.servers.RETRY` | `0D00:05` | +| `retry` | `.servers.RETRY` | `0D00:05`; also a `"0D00:00:10"` string or seconds | | `retain` | `.servers.RETAIN` | `` `long$0D00:30 `` | | `autoclean` | `.servers.AUTOCLEAN` | `0b` | | `debug` | `.servers.DEBUG` | `1b` | @@ -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; diff --git a/di/torq/servers/servers.q b/di/torq/servers/servers.q index f14a8f00..bf4ef09a 100644 --- a/di/torq/servers/servers.q +++ b/di/torq/servers/servers.q @@ -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; @@ -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}]; diff --git a/di/torq/servers/test.csv b/di/torq/servers/test.csv index cff12a65..b38c30c7 100644 --- a/di/torq/servers/test.csv +++ b/di/torq/servers/test.csv @@ -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 From 5c2dfe6db9c98344b797c78e0b2e92594b5b0cd6 Mon Sep 17 00:00:00 2001 From: alowrydi Date: Thu, 8 Oct 2026 15:52:20 +0100 Subject: [PATCH 2/2] Updating doc accuracy --- di/torq/servers/servers.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/di/torq/servers/servers.md b/di/torq/servers/servers.md index 0b33b6be..c2c548fb 100644 --- a/di/torq/servers/servers.md +++ b/di/torq/servers/servers.md @@ -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`; also a `"0D00:00:10"` string or seconds | +| `discoveryretry` | `.servers.DISCOVERYRETRY` | `0D00:05`; string or seconds allowed | | `tracknontorqprocess` | `.servers.TRACKNONTORQPROCESS` | `0b` | | `hopentimeout` | `.servers.HOPENTIMEOUT` | `2000` | -| `retry` | `.servers.RETRY` | `0D00:05`; also a `"0D00:00:10"` string or seconds | +| `retry` | `.servers.RETRY` | `0D00:05`; string or seconds allowed | | `retain` | `.servers.RETAIN` | `` `long$0D00:30 `` | | `autoclean` | `.servers.AUTOCLEAN` | `0b` | | `debug` | `.servers.DEBUG` | `1b` |