eigr / massa

A Stateful Serverless framework on the BEAM VM
https://eigr.io
Apache License 2.0
55 stars 5 forks source link

SideEffects as Broadcast #122

Open sleipnir opened 2 years ago

sleipnir commented 2 years ago

Today by the Cloudstate protocol you can emit many side effects (a list of them) but the proxy handles each side effect call individually. It would be interesting to allow the user role to emit a side effect for all entities registered in each of the Nodes of the cluster of a certain type. That is, to allow a call in Broadcast mode to be possible.

For that I see that we would have to change the SideEffect message to include a boolean flag to indicate this behavior. Something like:


// A side effect to be done after this command is handled.
message SideEffect {

    // The name of the service to perform the side effect on.
    string service_name = 1;

    // The name of the command.
    string command_name = 2;

    // The payload of the command.
    google.protobuf.Any payload = 3;

    // Whether this side effect should be performed synchronously, ie, before the reply is eventually
    // sent, or not.
    bool synchronous = 4;

    // Send side effect to all entities of the given type.
    bool broadcast = 6;

    // The metadata to include with the side effect
    Metadata metadata = 5;
}

``