Orleans.Sagas icon indicating copy to clipboard operation
Orleans.Sagas copied to clipboard

Functionality Proposal

Open ElanHasson opened this issue 3 years ago • 6 comments

Below is what is written to the mongo storage provider for grain state.

Is there a way to get at this information?

if not, are you open to a PR that does that, and also adds status information to the activity values

{ 
    "_id" : "GrainReference=422d0a3a946dfeb1a396449587bd519403ffffffc58d5186", 
    "_etag" : "c35f06df-184c-4aa4-80eb-c2ea78491a63", 
    "_doc" : {
        "__id" : "38", 
        "__type" : "Orleans.Sagas.SagaState, Orleans.Sagas", 
        "Activities" : {
            "__type" : "System.Collections.Generic.List`1[[Orleans.Sagas.ActivityDefinition, Orleans.Sagas]], System.Private.CoreLib", 
            "__values" : [
                {
                    "__id" : "39", 
                    "__type" : "Orleans.Sagas.ActivityDefinition, Orleans.Sagas", 
                    "Type" : "KitchenSink.Shared.Application.AddClientActivity, KitchenSink.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", 
                    "Properties" : {
                        "__id" : "40", 
                        "__type" : "Orleans.Sagas.SagaPropertyBag, Orleans.Sagas", 
                        "ContextProperties" : {
                            "__type" : "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.String, System.Private.CoreLib]], System.Private.CoreLib", 
                            "ClientName" : "{\"Name\":\"elsgwsa,lma[pn\"}"
                        }
                    }
                }, 
                {
                    "__id" : "41", 
                    "__type" : "Orleans.Sagas.ActivityDefinition, Orleans.Sagas", 
                    "Type" : "KitchenSink.Shared.Application.SetLegalNameActivity, KitchenSink.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", 
                    "Properties" : {
                        "__id" : "42", 
                        "__type" : "Orleans.Sagas.SagaPropertyBag, Orleans.Sagas", 
                        "ContextProperties" : {
                            "__type" : "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.String, System.Private.CoreLib]], System.Private.CoreLib", 
                            "LegalName" : "{\"Value\":\"Google, I;nc.\"}", 
                            "ClientName" : "{\"Name\":\"elsgwsa,lma[pn\"}"
                        }
                    }
                }
            ]
        }, 
        "NumCompletedActivities" : NumberInt(2), 
        "Status" : NumberInt(2), 
        "CompensationIndex" : NumberInt(0), 
        "HasBeenAborted" : false, 
        "Properties" : {
            "__id" : "43", 
            "__type" : "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.String, System.Private.CoreLib]], System.Private.CoreLib", 
            "AddClientActivity-Result" : "{\"Status\":4}", 
            "SetLegalNameActivityResult" : "{\"Events\":[],\"Status\":2}"
        }
    }
}

ElanHasson avatar Sep 29 '21 03:09 ElanHasson

What is the scope of what you want to expose? What is the goal of doing so? This state structure may evolve over time to support additional flows such as DAGs, so it's concerning to have it exposed in the client API.

creyke avatar Oct 01 '21 16:10 creyke

Hi @creyke,

Sorry this got lost in all of my notifications.

I'm looking to expose via a UI to show progress of the process to users, i.e. $"Out of the 5 activities in the saga, 3 of 5 are completed and we are still {Saga.Status}."

DAGs would be awesome, which also makes it harder to express the above sample UI statement.

I don't think leaking the underlying model is desirable-- as with everything, some sort of abstraction is necessary to hide internal implementation details.

Of course, the saga model for consumption would most likely be different, but derived from today's linear flow status.

It's also desirable to get access to the Saga Properties (global and activity) to gain more information by process managers (i.e. saga initiators) so they can decide what to do next.

I think this there is something that needs to happen around visibility into the execution of the flow in addition to what exists today.

Today though, I think there is an opportunity here to show individual activity status (i.e. "Pending", "Failed", "Active", etc)

Instead of sending a PR-- perhaps more discussion is appropriate for a longer term solution.

ElanHasson avatar Oct 06 '21 15:10 ElanHasson

I'm happy to discuss on a call for example, although alternatively you could propose an API-only PR which exposes the state-abstracted public objects you feel are appropriate as a starting point?

creyke avatar Oct 06 '21 15:10 creyke

Thanks Roger-- I may take you up on that, I'm on the Gitter.

When I circle back around to my saga work I'll take a stab at it.

ElanHasson avatar Oct 06 '21 16:10 ElanHasson

@ElanHasson did you ever end up doing this?

cecilphillip avatar Nov 23 '22 13:11 cecilphillip

Hi @cecilphillip,

Nope, I actually switched companies shortly after this.

ElanHasson avatar Nov 23 '22 13:11 ElanHasson