FunctionMonkey icon indicating copy to clipboard operation
FunctionMonkey copied to clipboard

Improvements suggestion: multiple output bindings

Open alexeymarkov opened this issue 5 years ago • 1 comments

Hi James,

Have you thought about adding a support of multiple output bindings? Imagine, in a POST/PUT/DELETE http function would like to

  • return a json
  • post a message to a queue (ServiceBus whatever) to notify other microservices about changes
  • post a message to SignalR to notify web clients about changes

One could use benefits of multiple output bindings and return a set of values. For instance,

class MultipleResult
{
public MyPoco ReturnResult { get; set; }
public string ServiceBusMessage { get; set; }
public SignalRMessage SignalRMessage  { get; set; }
}

class MyCommand : ICommand<MultipleResult>

Along with IFunctionOptions.OutputTo property there could be a method MultiOutputTo<TResult>(Expression<Func<TResult, object>> propertySelector) which would extract the property name from propertySelector and store it into a corresponding output binding class as an optional property name.

.MultiOutputTo<MultipleResult>(x => x.ServiceBusMessage).ServiceBusQueue(...) .MultiOutputTo<MultipleResult>(x => x.SignalRMessage).SignalRMessage(...)

Also something like IFunctionOptions.BindResultTo((Expression<Func<TResult, object>> propertySelector) to specify a property name to used as a function result (if any) would be necessary.

Sure, templates have to be adjusted.

What do you think?

Regards, Alexey

alexeymarkov avatar Feb 11 '20 09:02 alexeymarkov

I think its a good idea! I'll add it to the list! Thank you :)

JamesRandall avatar Feb 16 '20 17:02 JamesRandall