Skip to content
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

Adding service definitions for Projections #34

Merged
merged 9 commits into from
Mar 24, 2021
Merged

Conversation

jakhog
Copy link
Contributor

@jakhog jakhog commented Mar 22, 2021

This service definition (with messages) uses the same reverse call protocol that we use for Event Handlers and Filters.

The current suggestion is meant to support:

  1. Registering a projection by:
    • ID
    • Initial state (JSON string) that is used when a projection is first created (first event occurs for a key)
    • Selected events, by event type and key selector. Currently we support keys from:
      • EventSourceId
      • PartitionId
      • A named property on the event content
  2. Calculating new projection state as events occur. The key will be deduced by the Runtime, and along with the event the Runtime will send to the head the current (or initial) state for the projection with that key. The Head can then reply with either:
    • A REPLACE result, which overwrites the current state of the projection instance with the value provided
    • A DELETE result which deletes the projection instance. A new event with the same key would re-create the projection instance from initial state.

The suggestion is somewhat generic in terms of key selector and next state types, so we can if we want to allow more flexible or complex ways without breaking the Contracts in the future.

Copy link
Contributor

@woksin woksin left a comment

Choose a reason for hiding this comment

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

It seems like this should do the job.

One thing though, not really related to this, the mapping from key selector to to read model should be 1:1 IMO, we should not allow 1:* (?)

@woksin
Copy link
Contributor

woksin commented Mar 22, 2021

Can we release this as a prerelease? Would make it easier to work with, and we have the workflow for doing so :)

@woksin woksin changed the base branch from master to 5.3.0-projections March 23, 2021 08:34
@woksin
Copy link
Contributor

woksin commented Mar 23, 2021

@jakhog I changed the base of this PR so merging this will do a prerelease of 5.3.0-projections.

The releasing of javascript packages is disabled though. I'm having trouble even building them locally.

jakhog added 5 commits March 24, 2021 10:12
… newly created or already persisted, and handling of delete responses from head.
…lets leave that for later. We can send empty strings without much overhead for now (and it would be a non-breaking change in the future).
@jakhog jakhog marked this pull request as ready for review March 24, 2021 09:34
@jakhog jakhog requested a review from woksin March 24, 2021 09:34
Copy link
Contributor

@woksin woksin left a comment

Choose a reason for hiding this comment

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

This looks guud

@woksin woksin merged commit 2e610c3 into 5.3.0-projections Mar 24, 2021
@woksin woksin deleted the projections branch March 24, 2021 09:43
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