コード例 #1
0
ファイル: FabricResolver.cs プロジェクト: zbrad/FabricLib
        async Task<ResolvedServicePartition> getRsp(PartInfo part, ResolvedServicePartition prev)
        {
            ResolvedServicePartition rsp = null;

            try
            {               
                switch (part.Kind)
                {
                    case ServicePartitionKind.Singleton:
                        rsp = await Client.ServiceManager.ResolveServicePartitionAsync(part.Message.Headers.To, prev, this.timeout);
                        break;
                    case ServicePartitionKind.Int64Range:
                        rsp = await Client.ServiceManager.ResolveServicePartitionAsync(part.Message.Headers.To, part.RangeKey, prev, this.timeout);
                        break;
                    case ServicePartitionKind.Named:
                        rsp = await Client.ServiceManager.ResolveServicePartitionAsync(part.Message.Headers.To, part.NameKey, prev, this.timeout);
                        break;
                }
            }
            catch (AggregateException e)
            {
                log.Error(e, "Resolved for service {0} with partition key {1}. Found no endpoints.",
                    part.Message.Headers.To,
                    part.ToString());
                return null;
            }

            log.Info("Resolve for service {0} with partition key {1}. Found {2} endpoints.",
                        part.Message.Headers.To,
                        part.KindName,
                        rsp.Endpoints.Count);
            return rsp;
        }
コード例 #2
0
ファイル: FabricResolver.cs プロジェクト: zbrad/FabricLib
 async Task<Filter> createFilter(PartInfo part, FabricFilter old)
 {
     var prev = old == null ? null : old.ResolvedServicePartition;
     var rsp = await getRsp(part, prev);
     var ff = new FabricFilter();
     ff.Initialize(this.Retry, part, rsp);
     return ff;
 }
コード例 #3
0
ファイル: FabricResolver.cs プロジェクト: zbrad/FabricLib
 public override Task<Filter> CreateFilter(Message request)
 {
     var part = new PartInfo(request);
     log.Info("Create filter for service {0} with partition key {1}",
             request.Headers.To,
             part.ToString());
     return createFilter(part, null);
 }
コード例 #4
0
ファイル: FabricResolver.cs プロジェクト: zbrad/FabricLib
        public override Task <Filter> CreateFilter(Message request)
        {
            var part = new PartInfo(request);

            log.Info("Create filter for service {0} with partition key {1}",
                     request.Headers.To,
                     part.ToString());
            return(createFilter(part, null));
        }
コード例 #5
0
ファイル: FabricResolver.cs プロジェクト: zbrad/FabricLib
        async Task <Filter> createFilter(PartInfo part, FabricFilter old)
        {
            var prev = old == null ? null : old.ResolvedServicePartition;
            var rsp  = await getRsp(part, prev);

            var ff = new FabricFilter();

            ff.Initialize(this.Retry, part, rsp);
            return(ff);
        }
コード例 #6
0
ファイル: FabricResolver.cs プロジェクト: zbrad/FabricLib
        // This method is invoked by the host for every request message received. For every message received we
        // resolve the service address using the To address (service name) and the partition key using FabricClient.
        // The RouterTable is updated with the result.         
        public override Task<Filter> UpdateFilter(Message request, Filter oldfilter)
        {
            // if this is not a retry, then just reuse the existing filter
            if (!request.Headers.To.Equals(Retry))
                return Task.FromResult<Filter>(oldfilter);

            // we need to get an updated filter if client told us to retry
            var part = new PartInfo(request);
            log.Info("Updating filter for service {0} with partition key {1}",
                    request.Headers.To,
                    part.ToString());

            var oldFf = (FabricFilter)oldfilter;
            return createFilter(part, oldFf);
        }
コード例 #7
0
ファイル: FabricResolver.cs プロジェクト: zbrad/FabricLib
        // This method is invoked by the host for every request message received. For every message received we
        // resolve the service address using the To address (service name) and the partition key using FabricClient.
        // The RouterTable is updated with the result.
        public override Task <Filter> UpdateFilter(Message request, Filter oldfilter)
        {
            // if this is not a retry, then just reuse the existing filter
            if (!request.Headers.To.Equals(Retry))
            {
                return(Task.FromResult <Filter>(oldfilter));
            }

            // we need to get an updated filter if client told us to retry
            var part = new PartInfo(request);

            log.Info("Updating filter for service {0} with partition key {1}",
                     request.Headers.To,
                     part.ToString());

            var oldFf = (FabricFilter)oldfilter;

            return(createFilter(part, oldFf));
        }
コード例 #8
0
        public void Initialize(Uri retry, PartInfo part, F.ResolvedServicePartition rsp)
        {
            this.ResolvedServicePartition = rsp;
            this.Info = rsp.Info;
            this.Part = part;

            var uris = getUris();

            base.Initialize(part.Message.Headers.To, uris);

            // now add a router retry endpoint
            var retryEndpoint = new RouterEndpoint(
                this.Endpoints[0].Contract,
                this.Endpoints[0].Binding,
                new EndpointAddress(part.Message.Headers.To));

            retryEndpoint.Behaviors.Add(new ClientViaBehavior(retry));
            this.Endpoints.Add(retryEndpoint);
        }
コード例 #9
0
ファイル: FabricResolver.cs プロジェクト: zbrad/FabricLib
        async Task <ResolvedServicePartition> getRsp(PartInfo part, ResolvedServicePartition prev)
        {
            ResolvedServicePartition rsp = null;

            try
            {
                switch (part.Kind)
                {
                case ServicePartitionKind.Singleton:
                    rsp = await Client.ServiceManager.ResolveServicePartitionAsync(part.Message.Headers.To, prev, this.timeout);

                    break;

                case ServicePartitionKind.Int64Range:
                    rsp = await Client.ServiceManager.ResolveServicePartitionAsync(part.Message.Headers.To, part.RangeKey, prev, this.timeout);

                    break;

                case ServicePartitionKind.Named:
                    rsp = await Client.ServiceManager.ResolveServicePartitionAsync(part.Message.Headers.To, part.NameKey, prev, this.timeout);

                    break;
                }
            }
            catch (AggregateException e)
            {
                log.Error(e, "Resolved for service {0} with partition key {1}. Found no endpoints.",
                          part.Message.Headers.To,
                          part.ToString());
                return(null);
            }

            log.Info("Resolve for service {0} with partition key {1}. Found {2} endpoints.",
                     part.Message.Headers.To,
                     part.KindName,
                     rsp.Endpoints.Count);
            return(rsp);
        }