Repository navigation
di.torq.proc.gateway: register backends that connect after startup #145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alowrydi
merged 2 commits into
DataIntellectTech:main
from
DI-Dexter:fix-gateway-late-backend
Oct 16, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,46 @@ | ||
| / shared mocks for di.torq.proc.gateway's tests. di.serverselect, di.asyncdispatch and | ||
| / di.dataaccess are the REAL modules - only the four injected deps are mocked, so the tests | ||
| / exercise the registry the gateway actually routes on. | ||
|
|
||
| / --- log --- | ||
| calls:([]lvl:`symbol$();ctx:`symbol$();msg:()) | ||
| resetcalls:{[] `calls set ([]lvl:`symbol$();ctx:`symbol$();msg:()); } | ||
| mocklogfn:{[lvl;ctx;msg] `calls insert (lvl;ctx;msg); } | ||
| mocklog:{[] `info`warn`error!(mocklogfn[`info;;];mocklogfn[`warn;;];mocklogfn[`error;;])} | ||
|
|
||
| / --- timer / handlers: record the registration and do nothing --- | ||
| jobs:`symbol$() | ||
| mockaddjob:{[i;f;p;pe;m;o] `jobs set jobs,i; } | ||
| mocktimer:{[] `addjob`deletejobs`enablejobs`disablejobs`getactivejobs!(mockaddjob;{[x]};{[x]};{[x]};{[]()})} | ||
| mockhandlers:{[] `register`remove`list!({[e;n;nm;p;f]};{[e;n]};{[e]()})} | ||
|
|
||
| / --- servers --- | ||
| / BACKENDS is what di.torq.servers would report as connected. A test edits it to bring a | ||
| / backend "up" mid-session, which is the whole point: the gateway must notice. | ||
| BACKENDS:([]w:`int$();proctype:`symbol$();procname:`symbol$();hpup:`symbol$()) | ||
| setbackends:{[t] `BACKENDS set t; } | ||
|
|
||
| / only the hdb is up - the state the gateway starts in | ||
| hdbonly:{[] setbackends ([]w:enlist 7i;proctype:enlist`hdb;procname:enlist`hdb;hpup:enlist`:localhost:5302); } | ||
|
|
||
| / the rdb has since connected - what di.torq.servers' retry leaves behind | ||
| hdbandrdb:{[] setbackends ([]w:7 10i;proctype:`hdb`rdb;procname:`hdb`rdb1;hpup:`:localhost:5302`:localhost:5304); } | ||
|
|
||
| mockgetservers:{[pt] select from BACKENDS where proctype=pt} | ||
| mockservers:{[] `startup`getservers`gethandlebytype`waitfortype!({[c]};mockgetservers;{[pt;sel] 0Ni};{[pt;t;p] 1b})} | ||
|
|
||
| mockdeps:{[] `log`timer`handlers`servers!(mocklog[];mocktimer[];mockhandlers[];mockservers[])} | ||
|
|
||
| cfg:{[] (enlist`backendtypes)!enlist `rdb`hdb} | ||
|
|
||
| / what the gateway can actually ROUTE to: di.serverselect's table, which di.asyncdispatch | ||
| / dispatches on. Neither module exposes it, so the tests read it directly rather than have | ||
| / one of them grow an accessor for their benefit (same call as di.torq.proc.idb's tests). | ||
| routable:{[] exec distinct servertype from .m.di.0serverselect.servers where active} | ||
|
|
||
| / di.torq.servers fires .servers.connectcustom (from retryrows) after every successful new | ||
| / connection, and ships it as a no-op. 1b only once the gateway has replaced it with its own. | ||
| hookinstalled:{[] @[{100h=type value x};`.servers.connectcustom;{[e] 0b}]} | ||
|
|
||
| / fire the hook exactly as di.torq.servers' retryrows does - with the connected rows | ||
| fireconnectcustom:{[] (value `.servers.connectcustom) BACKENDS; } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set[.servers.connectcustom;{[rows] registerbackends[]}]unconditionally overwrites whatever was previously at.servers.connectcustom. Ifinitis called more than once (the consistency guide requires injected-moduleinitto be idempotent) the hook is re-installed harmlessly, but more importantly any third-party hook already registered at.servers.connectcustomby another module is silently discarded. The gateway should compose with the existing hook rather than replace it — e.g. capture the previous value and chain it:prev:@[value;.servers.connectcustom;{{[rows]}}]; set[.servers.connectcustom;{[rows] prev[rows]; registerbackends[]}]`.