예제 #1
0
    public static async Task <CommitEventsResponse> Commit(this IEventStore eventStore, UncommittedEvents events, Dolittle.Runtime.Execution.ExecutionContext executionContext)
    {
        var request = new CommitEventsRequest {
            CallContext = new CallRequestContext {
                ExecutionContext = executionContext.ToProtobuf()
            }
        };

        request.Events.AddRange(events.Select(_ => new UncommittedEventContract
        {
            Content       = _.Content,
            Public        = _.Public,
            EventType     = _.Type.ToProtobuf(),
            EventSourceId = _.EventSource
        }));
        var response = await eventStore.CommitEvents(request, CancellationToken.None).ConfigureAwait(false);

        return(response);
    }