/// <inheritdoc /> public async Task <Try <ProjectionIdentifierAndScope> > Resolve(MicroserviceAddress runtime, string identifierOrAlias, ScopeId scope = null) { var projections = await _client.GetAll(runtime).ConfigureAwait(false); var matchesWithoutScope = projections.Where(projection => projection.HasAlias ? projection.Alias.Value == identifierOrAlias : projection.Id.ToString() == identifierOrAlias ).ToList(); if (matchesWithoutScope.Count == 1) { return(new ProjectionIdentifierAndScope(matchesWithoutScope[0].Id, matchesWithoutScope[0].Scope)); } scope ??= ScopeId.Default; var matchesWithScope = matchesWithoutScope.Where(projection => projection.Scope == scope).ToList(); if (matchesWithScope.Count == 1) { return(new ProjectionIdentifierAndScope(matchesWithScope[0].Id, matchesWithScope[0].Scope)); } if (matchesWithoutScope.Count > 1) { return(new MultipleProjectionsWithIdentifierOrAliasInScope(identifierOrAlias, scope, matchesWithoutScope.Count)); } return(new NoProjectionWithIdentifierOrAliasInScope(identifierOrAlias, scope)); }
/// <inheritdoc /> public async Task <EventHandlerId> ResolveId(MicroserviceAddress runtime, EventHandlerIdOrAlias idOrAlias) { if (!idOrAlias.IsAlias) { return(idOrAlias.Id); } var statuses = await _managementClient.GetAll(runtime).ConfigureAwait(false); var status = statuses.FirstOrDefault(_ => WithAlias(_, idOrAlias)); if (status == default) { throw new NoEventHandlerWithId(idOrAlias.Alias); } return(status.Id); }
/// <inheritdoc /> public async Task <ArtifactId> ResolveId(MicroserviceAddress runtime, AggregateRootIdOrAlias idOrAlias) { if (!idOrAlias.IsAlias) { return(idOrAlias.Id); } var aggregateRoots = await _managementClient.GetAll(runtime).ConfigureAwait(false); var aggregateRoot = aggregateRoots.FirstOrDefault(_ => WithAlias(_, idOrAlias)); if (aggregateRoot == default) { throw new NoAggregateRootWithId(idOrAlias.Alias); } return(aggregateRoot.AggregateRoot.Identifier.Id); }
/// <inheritdoc /> public Task <IEnumerable <EventType> > Discover(MicroserviceAddress runtime) => _client.GetAll(runtime);