cloudstate icon indicating copy to clipboard operation
cloudstate copied to clipboard

Projection support

Open viktorklang opened this issue 5 years ago • 11 comments

TODO devise a solution for being able to consume domain events to facilitate things like creating projections, or even consuming domain events from something like Alpakka (CloudEvents?)

viktorklang avatar Apr 24 '19 07:04 viktorklang

@viktorklang, can we sync on that to avoid having different APIs? Unless this is something that needs to be completely different because of its nature.

But in any case, ultimately, it would be better if the underlying used API (not the one exposed to the client) is based on what we plan to build for general projections in Akka/Play/Lagom.

octonato avatar Apr 25 '19 07:04 octonato

@renatocaval This Issue is not about creating a new API, it's more to establish the flow to what they will create their projections from/using. Initially we're likely to either use the Akka Persistence projections or create an ingress for Pipelines.

viktorklang avatar Apr 25 '19 07:04 viktorklang

I got it. Thanks for the explanation.

octonato avatar Apr 25 '19 10:04 octonato

You’re most welcome! 🙂

Cheers, √

viktorklang avatar Apr 25 '19 11:04 viktorklang

So, this has turned out to be a bit of a yak shave. There's a lot of things to solve. My progress is here:

https://github.com/jroper/cloudstate/tree/eventing

I haven't even started on projection support, just getting things ready. Here's what I've implemented:

  • Modified it so the event source isn't a Source, it takes a Flow and is responsible for running it.
  • Made acknowledgements so they execute after the handler has returned (previously, they were executed in parallel to the handler handling the event, meaning event processing was at most once). This is why the Source takes a Flow, the output of the Flow is the acknowledgement message references.
  • Made the Google Pubsub support use the streaming call properly - we send one subscription call, send the messages in the pull response through the handler, and then route the acknowledgements back into the input of the call (a circular graph), rather than making separate gRPC calls for it.
  • Added a RestartSource so that when there's a network/io failure/application error etc, the stream restarts.
  • Implemented support for more than just serialized Anys on the wire. We now support JSON, plain text, plain bytes, and protobufs (not wrapped in Any). We use Cloudevents metadata to pass type information.
  • Added support for Cloudevents. This metadata is not yet sent to/from the user functions, but it will be.

I'm now pretty close to actually implementing the projection support.

jroper avatar Apr 07 '20 05:04 jroper

Nice @jroper !

ralphlaude avatar Apr 07 '20 15:04 ralphlaude

Hi ... Any new progress on this? I was wondering if it's possible to consume Kafka events and react to them using CloudState.

omidb avatar Jun 01 '20 00:06 omidb

@omidb Reacting to Kafka events seems more like a Eventing-related question. You can implement support for Kafka and plug that into the Eventing Support (currently on Google Cloud PubSub support is built in).

viktorklang avatar Jun 01 '20 09:06 viktorklang

@viktorklang Would you please point me to the docs for Eventing Support?

omidb avatar Jun 01 '20 17:06 omidb

@omidb It has not been officially released yet, but you can see it here:

https://github.com/cloudstateio/cloudstate/blob/master/proxy/core/src/main/resources/reference.conf#L76

And how it can be used here: https://github.com/cloudstateio/cloudstate/blob/master/protocols/example/shoppingcart/shoppingcart.proto#L47

viktorklang avatar Jun 02 '20 09:06 viktorklang

Current status video by @jroper - https://youtu.be/lan5Awqy-xI

kikiya avatar Jul 30 '20 16:07 kikiya