flogo-lib icon indicating copy to clipboard operation
flogo-lib copied to clipboard

Shared objects across activities

Open mellistibco opened this issue 7 years ago • 4 comments

Shared resources or objects, such as connections should be shared across activities, thus avoiding the need to reestablish connections for every activity (MQTT publish for example).

Basically the activities can belong to several flows, not all of which will have the same configuration for something like an MQTT client. The solution to this would be to have a "shared resource" in which activities that use the same configuration can reference

Reference #111

mellistibco avatar Oct 05 '17 15:10 mellistibco

As suggested in #111 in this comment, different scopes of shared resources could be implemented, being the activity attributes a natural one, and flow and application level two more that may be interesting.

Adirio avatar Oct 06 '17 10:10 Adirio

Some thoughts: Working on another project I thought that context could be used for this. A ctx could be passed though activity.Init() and trigger.Init() to populate it with the shared resources. Then this context would be passed to trigger.Start() instead of creating a new one from context.Background() and it should also be passed to trigger.Stop() and activity.Eval().

Adirio avatar Oct 18 '17 08:10 Adirio

Thanks Adirio. Shortly I'm going to start looking into both how best to share resources and also possible activity initialization based on both app and the particular action/flow it belongs to. I'll keep you posted.

fm-tibco avatar Oct 18 '17 17:10 fm-tibco

I've realised that what you are passing to activity.Eval(), despite being named activity.Context it is not a context.Context as I was expecting (similar to the extra abstraction layer you are using on trigger.NewContext). Is the activity.Context an abstraction layer over context.Context or is it a completely different thing? Because my thought was based on the fact that you were already passing some kind of context.Context to activity.Eval().

Adirio avatar Oct 19 '17 12:10 Adirio