Netflix / glisten

Ease of use Groovy library for building JVM applications with Amazon Simple Workflow (SWF)
Apache License 2.0
67 stars 31 forks source link

Support passing promises to activities #29

Open sjones4 opened 10 years ago

sjones4 commented 10 years ago

It is not currently possible (out of the box) to pass a promise to an activity from a workflow with glisten. Currently you would use something like:

  interface MyActivities {
    String myActivity( String )
  }

  waitFor( myPromise ) { String promised ->
    activities.myActivity( promised  )
  }

rather than the approach you can use with the flow framework:

  promisedActivities.myActivity( myPromise )

so passing the promise directly. In the above example promisedActivities could be a (caller for an) interface generated based on the regular activities interface but with all parameters wrapped in a promise (as with the methods generated by the flow framework via APT):

  @GlistenTheseActivities
  interface MyPromisedActivities extends MyActivities {
    // Generated method:
    // String myActivity( Promise<String> )
  }

With Groovy, generation of the interface could be done via AST so would not require any special configuration and would be opt-in (via annotation). To invoke there would be a modification/variation of AsyncCaller that did not wrap parameters with promises.

It seems beneficial to allow passing promises from workflows, but I'm not sure if this fits with the motivations for glisten (or if this functionality is not necessary for some reason)