public EventLogStreamActor( ChannelWriter <EventLogBatch> channelWriter, ScopeId scope, EventLogSequenceNumber nextOffset, IReadOnlyCollection <ArtifactId> eventTypeIds, EventStoreClient eventStoreClient, ILogger <EventLogStreamActor> logger, CancellationToken cancellationToken) { _channelWriter = channelWriter; _nextOffset = nextOffset; _eventTypes = eventTypeIds; _eventStoreClient = eventStoreClient; _logger = logger; _cancellationToken = cancellationToken; _subscriptionId = Guid.NewGuid().ToProtobuf(); _scope = scope.ToProtobuf(); }
/// <inheritdoc /> public async Task <Try> Replay(MicroserviceAddress runtime, ScopeId scope, ProjectionId projection, TenantId tenant = null) { var client = _clients.CreateClientFor <ProjectionsClient>(runtime); var request = new ReplayProjectionRequest { ScopeId = scope.ToProtobuf(), ProjectionId = projection.ToProtobuf(), TenantId = tenant?.ToProtobuf(), }; var response = await client.ReplayAsync(request); if (response.Failure != null) { return(new ReplayProjectionFailed(scope, projection, response.Failure.Reason)); } return(Try.Succeeded()); }
/// <inheritdoc /> public async Task <Try <ProjectionStatus> > Get(MicroserviceAddress runtime, ScopeId scope, ProjectionId projection, TenantId tenant = null) { var client = _clients.CreateClientFor <ProjectionsClient>(runtime); var request = new GetOneProjectionRequest { ScopeId = scope.ToProtobuf(), ProjectionId = projection.ToProtobuf(), TenantId = tenant?.ToProtobuf() }; var response = await client.GetOneAsync(request); if (response.Failure != null) { return(new GetOneProjectionFailed(scope, projection, response.Failure.Reason)); } return(CreateProjectionStatus(response.Projection)); }
/// <inheritdoc/> protected override EventHandlerRegistrationRequest GetRegisterArguments() { var request = new EventHandlerRegistrationRequest { EventHandlerId = Identifier.ToProtobuf(), ScopeId = _scope.ToProtobuf(), Partitioned = _partitioned, }; foreach (var eventType in _handler.HandledEventTypes) { var artifact = _artifacts.GetArtifactFor(eventType); request.Types_.Add(new Artifact { Id = artifact.Id.ToProtobuf(), Generation = artifact.Generation, }); } return(request); }
/// <inheritdoc /> public async Task Commit(CommittedEvents events, ConsentId consent, ScopeId scope) { foreach (var @event in events) { var sequenceNumber = await _policies.WriteEvent.ExecuteAsync( _ => _receivedEventsWriter.Write(@event, consent, scope, CancellationToken.None), CancellationToken.None).ConfigureAwait(false); await _eventStoreClient.CommitExternal(new CommitExternalEventsRequest { ScopeId = scope.ToProtobuf(), Event = new CommittedEvent( sequenceNumber, @event.Occurred, @event.EventSource, @event.ExecutionContext, @event.Type, @event.Public, @event.Content).ToProtobuf() }, CancellationToken.None).ConfigureAwait(false); } }
/// <inheritdoc/> protected override FilterRegistrationRequest GetRegisterArguments() => new FilterRegistrationRequest { FilterId = Identifier.ToProtobuf(), ScopeId = _scope.ToProtobuf(), };