Ejemplo n.º 1
0
        public IConsumedMethodReference CreateConsumedMethodReference(IConsumedServiceReference consumedService, string methodId)
        {
            var obj = ConsumedMethodReference.Rent();

            obj.ConsumedService = consumedService;
            obj.MethodId        = methodId;
            return(obj);
        }
        private static ConsumedServiceReference ConvertToProtoStrict(IConsumedServiceReference obj)
        {
            var proto = ConsumedServiceReference.Rent();

            proto.ServiceId    = obj.ServiceId.ConvertToProtoStrict();
            proto.ServiceAlias = obj.ServiceAlias.ConvertToProto();
            return(proto);
        }
Ejemplo n.º 3
0
        public IDiscoveredService CreateDiscoveredService(
            IConsumedServiceReference consumedService,
            IProvidedServiceReference providedService,
            Maybe <string> serviceTitle,
            IReadOnlyCollection <IDiscoveredServiceMethod> methods)
        {
            var obj = DiscoveredService.Rent();

            obj.ConsumedService = consumedService;
            obj.ProvidedService = providedService;
            obj.ServiceTitle    = serviceTitle;
            obj.Methods         = methods;
            return(obj);
        }
Ejemplo n.º 4
0
 public IConsumedService GetConsumedService(string appId, IConsumedServiceReference reference)
 {
     _registryLock.EnterReadLock();
     try
     {
         return(_registry.Applications[appId].ConsumedServices
                .FirstOrDefault(x =>
                                Equals(x.Service.Id, reference.ServiceId) && Equals(x.Alias, reference.ServiceAlias)));
     }
     finally
     {
         _registryLock.ExitReadLock();
     }
 }
Ejemplo n.º 5
0
 public IConsumedService GetConsumedService(string appId, IConsumedServiceReference reference)
 {
     _registryLock.EnterReadLock();
     try
     {
         var application     = GetApplication(appId);
         var consumedService = application.ConsumedServices
                               .FirstOrDefault(service => Equals(service.Service.Id, reference.ServiceId) && Equals(service.Alias, reference.ServiceAlias));
         if (consumedService != null)
         {
             return(consumedService);
         }
         throw new MetadataViolationException($"Service {reference.ServiceId} with alias {reference.ServiceAlias} do not exist or is not consumed by {appId} application. Available services: {string.Join(", ", application.ConsumedServices.Select(service => service.Service.Id))}");
     }
     finally
     {
         _registryLock.ExitReadLock();
     }
 }
Ejemplo n.º 6
0
 public IReadOnlyCollection <(IConsumedMethod Consumed, IProvidedMethod Provided)> GetMethodMatches(string appId, IConsumedServiceReference consumedServiceReference)
 {
     _registryLock.EnterReadLock();
     try
     {
         var consumedService = GetConsumedService(appId, consumedServiceReference);
         return(GetMatchingProvidedMethods(consumedService.Application)
                .Join(consumedService.Methods.Values, x => x.Method, y => y.Method, (x, y) => (y, x))
                .Distinct()
                .ToList());
     }
     finally
     {
         _registryLock.ExitReadLock();
     }
 }