serverless/fdk

trigger method

Closed this issue · 7 comments

Almost the same as sync call method:

sdk.trigger('sendWelcomeEmail', 'test@exmaple.com', callback)

trigger(name, args, callback)

Parameters:

  • name - string|array - function name(s)
  • args - any type - arguments to pass to called function
  • callback - function - takes err and result. callback parameter informs if trigger has been successfully submitted. It doesn't mean that function has been called.

Currently there is no way to provide configurable retry logic. It's worth to read how it's solved in AWS (http://docs.aws.amazon.com/lambda/latest/dg/retries-on-errors.html).

Is there a place for a correlationId as part of the signature? Or should users handle that themselves in args?

@mthenw I wonder if this is something we even want to support. I don't know any case where I wouldn't recommend setting up SNS for delayed invocation. Would be nice if we had a helper for that from my perspective.

@nikgraf what if you want a result back? This is similar to call which I think is awesome btw. I often want the results back from invoking a Lambda. It's an awesome pattern with GraphQL. i.e. this resolver.

I think there's also a use case for a trigger function. That would use SNS to fire an event and not care about the response.

@nikgraf AFAIR there is no big difference between invoking lambda async and using SNS for that. In both cases retry logic is similar (if not the same) and isn't configurable.

@johncmckim

I think there's also a use case for a trigger function. That would use SNS to fire an event and not care about the response.

This is exactly what I mean when created that issue. As I answered above there is no need to use SNS for that.

Actually I renamed it to trigger for now. It makes more sense.

Going to close this now as we creating a new FDK and going to call it emit there