feat(jetstream): add consumers.createOrUpdate#412
Conversation
Mirrors CreateOrUpdateConsumer in the Go client. Also switches addUpdate's action default from || to ?? so the empty-string CreateOrUpdate action isn't silently coerced back to "create". Signed-off-by: Styler <styler@streamelements.com>
|
Claude finished @styler's task in 2m 4s —— View job PR Review: feat(jetstream): add consumers.createOrUpdate
Overall AssessmentThe change is small, correct, and follows existing conventions. Two observations below.
Two things worth addressing before merge:
No security or async issues found. Cross-runtime compatibility is unaffected (no runtime-specific code paths). |
|
|
||
| // createOrUpdate must accept the modified config and apply it | ||
| const ci = await jsm.consumers.createOrUpdate("stream", config); | ||
| assertEquals(ci.config.inactive_threshold, nanos(60 * 1000)); |
There was a problem hiding this comment.
The test only covers the update path (existing consumer, modified config). It would be good to also assert the create path — e.g. call createOrUpdate for a consumer name that doesn't exist yet and verify it succeeds without error. That's the other half of "create or update".
There was a problem hiding this comment.
Added — covers a fresh durable name in the same test.
| return this.addUpdate(stream, cfg, cco); | ||
| } | ||
|
|
||
| createOrUpdate( |
There was a problem hiding this comment.
The interface in types.ts declares cfg: Partial<ConsumerConfig>, but this implementation uses cfg: ConsumerConfig. This follows the same pattern as add, so it's consistent with the existing convention — just flagging it in case the intent is to accept genuinely partial configs (the implementation and the underlying addUpdate both require a full ConsumerConfig).
There was a problem hiding this comment.
Matching add's signature on purpose — the impl/interface mismatch predates this PR and applies to add too. Would rather fix both in a follow-up than diverge here.
There was a problem hiding this comment.
Minor nit - there's no create in the ConsumerAPI, so addOrUpdate possibly is more consistent? wdyt?
Signed-off-by: Styler <styler@streamelements.com>
Mirrors
CreateOrUpdateConsumerin the Go client — useful for KV/object-store init paths and any caller that wants idempotent setup without doing the info-then-decide dance themselves.Also a small fix in
addUpdate: the action default used||, which coerced the empty-stringCreateOrUpdatevalue back to"create". Changed to??so the action survives. Today this only matters for the newcreateOrUpdatepath (the existingadd/updatecallers always pass a truthy action), but worth fixing in the same PR since the new method depends on it.