Add experimental in-process observation for Drizzle read models - #89
Merged
Merged
Conversation
Resolve RxJS observable base types and typed service-token query bindings so Drizzle observe() generates an observable array proxy. Refs #53
Reject disabled observation; buffer by tenant, schedule re-reads outside the publisher context and release failed primes. Split and extend behavioral specs for HTTP, SSE, hub and lifecycle cases. Refs #53
Use small-array model-bound queries, restrict SQL page streams to low-level definitions, explain runner order and list rxjs as a required peer. Refs #53
Move shared race setup into a given context and assert outcomes after each scenario action. Refs #53
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Arc for TypeScript 0.38.0 adds experimental live observation for Drizzle SQL read models, the counterpart of
Observe()on Entity Framework Core read models in Arc for .NET, limited to changes announced in the same process. npm publication remains disabled.Added
withDrizzle({ observation: DrizzleObservation.InProcess }).DrizzleReadModels.observe(filter?)andobserveById(key)return a live RxJS observable withcurrent(), which model-bound observable queries can return and serve over SSE and WebSocket like any observable query.observePage(filter, options)emitsQueryPageresults for low-leveldefineObservableQuerydefinitions; generated proxies don't support observable pages yet.DrizzleHandle.notifyChanged(tableOrReadModelType)announces a write. Inside an Arc command, notifications from the command and its nested commands are published once, when the outermost command finishes (also when it fails). Outside a command they are published immediately.ObservableorSubject, such as the observables returned by MongoDB and Drizzle read models, and asks for anObservable<...>annotation when it can't resolve the item type.Changed
rxjsis now a required peer dependency of@cratis/arc.drizzle.Observation is experimental and deliberately narrow: only writes announced with
notifyChangedin the same process and tenant are observed, pages are eventually consistent, a transaction the host holds around the whole Arc call must notify after it commits, and starting an observation without the opt-in fails instead of returning a stream that never updates. Cross-process change detection, such as PostgreSQLLISTEN/NOTIFY, is not included.Refs #53