Skip to content

di.torq.proc.gateway - syncexec syncexecj calls added to gateway - #170

Open
DanielPyper wants to merge 2 commits into
mainfrom
Bench-333-Addition-syncexec-syncexecj
Open

DanielPyper wants to merge 2 commits into
mainfrom
Bench-333-Addition-syncexec-syncexecj

Conversation

@DanielPyper

Copy link
Copy Markdown

Addition of syncexec & syncexecj to gateway

di.torq.proc.gateway: publish .gw.syncexec and .gw.syncexecj

Summary

The gateway published only .gw.asyncexec and .gw.asyncexecjpt. This adds TorQ's synchronous entry points on top of di.asyncdispatch's existing deferred-reply support (-30!):

  • .gw.syncexec[query;servertypes] – results razed
  • .gw.syncexecj[query;servertypes;join] – custom join function

Both are additive: asyncexec, asyncexecjpt, getdata and ineod are unchanged. The calls are deferred, not blocking a sync call does not hold the gateway for other clients. They are gated by synccallsallowed (default false).

Rejections (EOD reload, permissions) are signalled as errors to the caller, as legacy's formatresponse does for sync. The async path's neg .z.w reply would leave a sync caller waiting. EOD reload to be looked at after this as presents a bigger lift and need to discuss prior to beginning

Also: removes di.dataaccess from the Deferred bullet as this has been created in gateway.md (it is already in use via .gw.getdata), and bumps the module VERSION 0.3.0 → 0.4.0.

Changes

  • gateway.q, init.q: syncexecj, syncexec, published at root and exported
  • test.csv, test.q: real-process fixture runs with synccallsallowed on; new sync rows
  • gateway.md: client API, EOD list, config comment, Deferred bullet
  • VERSION: 0.4.0

Testing

  • k4unit.moduletest passes for di.torq.proc.gateway and di.asyncdispatch. New rows cover: syncexec razing across rdb+hdb, syncexecj with a join, EOD reload (multi-type rejected and nothing sent, single-type runs), and the "not allowed" error when synccallsallowed is off.

Rerunning the di.anydsipatch unit tests & the gateway unit tests
GetImage (1)
GetImage (2)

  • Run on the TorqX-POC stack against gateway1 (screenshots attached): syncexec and syncexecj return correct results and match asyncexec when synccallsallowed=true when we set synccallsallowed=false in the secodn screenshots we can see it still rejects sync but accepts async.
GetImage (3) GetImage (4)

asyncexec:{[query;servertype] asyncexecjpt[query;servertype;raze;();0Wn]}

/ client entry point .gw.syncexecj: deferred-sync reply; rejections are signalled as errors
syncexecj:{[query;servertype;join]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The permissioned guard references .z.m.permissioned and calls permitted[u;query], but neither of these symbols appear to be set up anywhere in the diff. syncexecj is a new entry point added in this diff, and if the permission infrastructure is not initialised in the module's init path (which is not shown as changed here), .z.m.permissioned will be undefined and the guard will throw at runtime. Verify that .z.m.permissioned is populated during init (the same way asyncexecjpt guards it, if it does).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

permissioned and permitted "not set up" (not valid)

  • Both exist. permitted is defined at the top of gateway.q, outside the diff, and init sets .z.m.permissioned (.z.m.permissioned:$[permissioned in key config;boolean$configpermissioned;0b]`). The bot only saw the diff.
  • syncexecj uses them exactly as asyncexecjpt does, so it's no riskier than the existing async path.
  • It was also exercised live: the POC gateway runs with permissioned = true, and syncexec returned correct results as torqx.

true,0,0,q,0 0~S3`sent,1,,and nothing is sent
run,0,0,q,S4:gwsync(`.gw.syncexec;"count trade";`hdb),1,,syncexec to the hdb alone during the reload
true,0,0,q,(enlist 2)~S4`res,1,,a single-type syncexec runs during the reload
true,0,0,q,0 1~S4`sent,1,,and is sent to the hdb only

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test at line 70 (S5) expects the error message "syncexec: synchronous calls are not allowed" when synccallsallowed is off, but syncexec delegates directly to syncexecj via syncexecj[;;raze], and syncexecj itself calls (.z.m.adexecquery)which isdi.asyncdispatch's execquery. The error text "syncexec: synchronous calls are not allowed"would be produced insidedi.asyncdispatch— if that module's error text differs, the test will fail. Additionally, the test manually sets.m.di.0asyncdispatch.synccallsallowed:0b` directly in the gateway's private namespace (line 69); if the asyncdispatch module reads this flag under a different internal path the override silently has no effect.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S5 error text and the private-namespace override (not valid)

  • Error text: the text is produced in di.asyncdispatch's execquery (asyncdispatch.q line 254) and matches the test's literal string exactly. The test passed, so it's not a mismatch.
  • Namespace override: the path .m.di.0asyncdispatch.synccallsallowed is already used by existing gateway rows, and init rows 16–18 of test.csv read it back. The override also demonstrably worked: the same syncexec call succeeded earlier in the run, then errored after the flag was set to 0b, and the S5 row also asserts 0 0~S5sent``.
  • Fair point: the test is coupled to another module's error wording. If that wording changes, the test fails loudly, which is arguably what you'd want.

@DI-Software-Engineering

Copy link
Copy Markdown

DIReview Summary

0 critical | 2 warning(s) | 1 suggestion(s)

⚠️ Spec check skipped — tracker lookup failed (NO_REF_FOUND). Standards axis only.

Suggestions

  • di/torq/proc/gateway/test.q:88 — gwsync sends SENT:0 to reset counters on each backend before the call, then reads SENT after. The reset and read are two separate synchronous IPC calls per backend handle, but the actual gateway call GWH;m happens between reset and read with no serialisation guarantee against the backends processing earlier in-flight async messages — a lingering async reply dispatched between the reset and the GWH call could inflate SENT. More critically, SENT:0 is an assignment expression evaluated on the backend via "SENT:0", but SENT is likely a root variable on each backend process; if the backend uses a use-loaded module the write may land in the module namespace rather than root, making the counter reset a silent no-op and all sent assertions unreliable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants