rebus-org / Rebus

:bus: Simple and lean service bus implementation for .NET
https://mookid.dk/category/rebus
Other
2.3k stars 356 forks source link

Overloads for saga correlation methods #883

Closed seankearon closed 4 years ago

seankearon commented 4 years ago

When we correlate messages that participate in sagas against their data, we use an Expression as the second parameter. Like this example from the wiki:

    protected override void CorrelateMessages(ICorrelationConfig<CollectLegalInfoSagaData> config)
    {
        config.Correlate<CustomerCreated>(m => m.CustomerId, d => d.CrmCustomerId);
        config.Correlate<LegalInfoAcquiredInFirstSystem>(m => m.CorrId, d => d.CrmCustomerId);
        config.Correlate<LegalInfoAcquiredInSecondSystem>(m => m.CorrId, d => d.CrmCustomerId);
    }

I think this parameter is only used to identify the name of the property in the SagaData.

Would it be sensible to have an overload for the second parameter that allowed us to pass a string? For example:

    protected override void CorrelateMessages(ICorrelationConfig<CollectLegalInfoSagaData> config)
    {
        config.Correlate<CustomerCreated>(m => m.CustomerId, nameof(CollectLegalInfoSagaData.CrmCustomerId));
    }

My motivation is to make it easier to use a saga from another language, F# in this case.

I think this would also apply to the other methods in ICorrelationConfig.cs also.

mookid8000 commented 4 years ago

Yes, that would actually be great šŸ™‚

seankearon commented 4 years ago

Great! How does this look? šŸš€

mookid8000 commented 4 years ago

Fixed in Rebus 6.3.0 šŸ¤˜