Exemple #1
0
 /// <inheritdoc/>
 public IEventProcessor GetFor <TEventType>(EventHandlerId id, ScopeId scope, bool partitioned, IEventHandler <TEventType> handler)
     where TEventType : IEvent
 => new EventHandlerProcessor <TEventType>(
     id,
     scope,
     partitioned,
     handler,
     _handlersClient,
     _reverseCallClients,
     _eventProcessingCompletion,
     _artifactTypeMap,
     _converter,
     _loggerManager.CreateLogger <EventHandlerProcessor <TEventType> >());
Exemple #2
0
    /// <inheritdoc />
    public async Task ReprocessAllEvents(EventHandlerId eventHandler, MicroserviceAddress runtime)
    {
        var client = _clients.CreateClientFor <EventHandlersClient>(runtime);

        var request = new ReprocessAllEventsRequest
        {
            ScopeId        = eventHandler.Scope.ToProtobuf(),
            EventHandlerId = eventHandler.EventHandler.ToProtobuf(),
        };

        var response = await client.ReprocessAllEventsAsync(request);

        if (response.Failure != null)
        {
            throw new ReprocessAllEventsFailed(response.Failure.Reason);
        }
    }
Exemple #3
0
    /// <inheritdoc />
    public async Task <Try <EventHandlerStatus> > Get(MicroserviceAddress runtime, EventHandlerId eventHandler, TenantId tenant = null)
    {
        var client  = _clients.CreateClientFor <EventHandlersClient>(runtime);
        var request = new GetOneRequest
        {
            EventHandlerId = eventHandler.EventHandler.ToProtobuf(),
            ScopeId        = eventHandler.Scope.ToProtobuf(),
            TenantId       = tenant?.ToProtobuf()
        };

        var response = await client.GetOneAsync(request);

        if (response.Failure != null)
        {
            throw new GetOneEventHandlerFailed(eventHandler, response.Failure.Reason);
        }

        return(CreateEventHandlerStatus(response.EventHandlers));
    }
Exemple #4
0
    /// <inheritdoc />
    public async Task ReprocessEventsFrom(EventHandlerId eventHandler, TenantId tenant, StreamPosition position, MicroserviceAddress runtime)
    {
        var client = _clients.CreateClientFor <EventHandlersClient>(runtime);

        var request = new ReprocessEventsFromRequest
        {
            ScopeId        = eventHandler.Scope.ToProtobuf(),
            EventHandlerId = eventHandler.EventHandler.ToProtobuf(),
            TenantId       = tenant.ToProtobuf(),
            StreamPosition = position,
        };

        var response = await client.ReprocessEventsFromAsync(request);

        if (response.Failure != null)
        {
            throw new ReprocessEventsFromFailed(response.Failure.Reason);
        }
    }
 /// <summary>
 /// Initializes a new instance of the <see cref="EventHandlerProcessor{TEventType}"/> class.
 /// </summary>
 /// <param name="handlerId">The unique <see cref="EventHandlerId"/> for the event handler.</param>
 /// <param name="scope">The <see cref="ScopeId"/> of the scope in the Event Store where the event handler will run.</param>
 /// <param name="partitioned">Whether the event handler should create a partitioned stream or not.</param>
 /// <param name="handler">The <see cref="IEventHandler{TEventType}"/> that will be called to handle incoming events.</param>
 /// <param name="client">The <see cref="EventHandlersClient"/> to use to connect to the Runtime.</param>
 /// <param name="reverseCallClients">The <see cref="IReverseCallClients"/> to use for creating instances of <see cref="IReverseCallClient{TClientMessage, TServerMessage, TConnectArguments, TConnectResponse, TRequest, TResponse}"/>.</param>
 /// <param name="completion">The <see cref="IEventProcessingCompletion"/> to use for notifying of event handling completion.</param>
 /// <param name="artifacts">The <see cref="IArtifactTypeMap"/> to use for converting event types to artifacts.</param>
 /// <param name="converter">The <see cref="IEventConverter"/> to use to convert events.</param>
 /// <param name="logger">The <see cref="ILogger"/> to use for logging.</param>
 public EventHandlerProcessor(
     EventHandlerId handlerId,
     ScopeId scope,
     bool partitioned,
     IEventHandler <TEventType> handler,
     EventHandlersClient client,
     IReverseCallClients reverseCallClients,
     IEventProcessingCompletion completion,
     IArtifactTypeMap artifacts,
     IEventConverter converter,
     ILogger logger)
     : base(logger)
 {
     Identifier          = handlerId;
     _scope              = scope;
     _partitioned        = partitioned;
     _handler            = handler;
     _client             = client;
     _reverseCallClients = reverseCallClients;
     _completion         = completion;
     _artifacts          = artifacts;
     _converter          = converter;
     _logger             = logger;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="NoEventHandlerWithId"/> class.
 /// </summary>
 /// <param name="id">The Event Handler identifier.</param>
 public NoEventHandlerWithId(EventHandlerId id)
     : base($"There is no registered Event Handler with Id '{id.EventHandler.Value}' in Scope '{id.Scope.Value}'")
 {
 }
Exemple #7
0
 internal static partial void EventHandlerAlreadyRegistered(this ILogger logger, EventHandlerId eventHandler);
 /// <summary>
 /// Initializes an instance of the <see cref="EventHandlerNotRegistered"/> class.
 /// </summary>
 /// <param name="eventHandler">The <see cref="EventHandlerId"/>.</param>
 public EventHandlerNotRegistered(EventHandlerId eventHandler)
     : base($"Event handler {eventHandler} is not registered")
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="GetOneEventHandlerFailed"/> class.
 /// </summary>
 /// <param name="eventHandler">The Event Handler that getting one failed for.</param>
 /// <param name="reason">The reason why getting one Event Handler failed.</param>
 public GetOneEventHandlerFailed(EventHandlerId eventHandler, string reason)
     : base($"Could not get event handler {eventHandler.EventHandler} in scope {eventHandler.Scope} because {reason}")
 {
 }