/// <inheritdoc /> public async Task <IEnumerable <AggregateRootWithTenantScopedInstances> > GetAll(MicroserviceAddress runtime, TenantId tenant = null) { var client = _clients.CreateClientFor <AggregateRootsClient>(runtime); var request = new GetAllRequest { TenantId = tenant?.ToProtobuf() }; var response = await client.GetAllAsync(request); if (response.Failure is not null) { throw new GetAllFailed(response.Failure.Reason); } return(response.AggregateRoots.Select(FromProtobuf)); }
/// <inheritdoc /> public async Task <IEnumerable <EventHandlerStatus> > GetAll(MicroserviceAddress runtime, TenantId tenant = null) { var client = _clients.CreateClientFor <EventHandlersClient>(runtime); var request = new GetAllRequest { TenantId = tenant?.ToProtobuf() }; var response = await client.GetAllAsync(request); if (response.Failure != null) { throw new GetAllEventHandlersFailed(response.Failure.Reason); } return(response.EventHandlers.Select(CreateEventHandlerStatus)); }
/// <inheritdoc /> public async Task <Try <AggregateRootWithTenantScopedInstances> > Get(MicroserviceAddress runtime, ArtifactId aggregateRootId, TenantId tenant = null) { var client = _clients.CreateClientFor <AggregateRootsClient>(runtime); var request = new GetOneRequest() { TenantId = tenant?.ToProtobuf(), AggregateRootId = aggregateRootId.ToProtobuf() }; var response = await client.GetOneAsync(request); if (response.Failure is not null) { return(new GetOneFailed(response.Failure.Reason)); } return(FromProtobuf(response.AggregateRoot)); }
/// <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 /> 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)); }
/// <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); } }
/// <inheritdoc /> public async Task <CommittedAggregateEvents> GetEvents(MicroserviceAddress runtime, ArtifactId aggregateRootId, EventSourceId eventSourceId, TenantId tenant = null) { var client = _clients.CreateClientFor <AggregateRootsClient>(runtime); var request = new GetEventsRequest() { TenantId = tenant?.ToProtobuf(), Aggregate = new Aggregate { AggregateRootId = aggregateRootId.ToProtobuf(), EventSourceId = eventSourceId } }; var response = await client.GetEventsAsync(request); if (response.Failure is not null) { throw new GetEventsFailed(response.Failure.Reason); } return(FromProtobuf(response.Events)); }