Exemplo n.º 1
0
 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();
 }
Exemplo n.º 2
0
    /// <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());
    }
Exemplo n.º 3
0
    /// <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);
        }
Exemplo n.º 5
0
    /// <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);
        }
    }
Exemplo n.º 6
0
 /// <inheritdoc/>
 protected override FilterRegistrationRequest GetRegisterArguments()
 => new FilterRegistrationRequest
 {
     FilterId = Identifier.ToProtobuf(),
     ScopeId  = _scope.ToProtobuf(),
 };