示例#1
0
        private ChannelRef PreProcess <TRequest>(AffinityConfig affinityConfig, TRequest request)
        {
            // Gets the affinity bound key if required in the request method.
            string boundKey = null;

            if (affinityConfig != null && affinityConfig.Command == AffinityConfig.Types.Command.Bound)
            {
                boundKey = GetAffinityKeysFromProto(affinityConfig.AffinityKey, (IMessage)request).SingleOrDefault();
            }

            ChannelRef channelRef = GetChannelRef(boundKey);

            channelRef.ActiveStreamCountIncr();
            return(channelRef);
        }
示例#2
0
 // Note: response may be default(TResponse) in the case of a failure. We only expect to be called from
 // protobuf-based calls anyway, so it will always be a class type, and will never be null for success cases.
 // We can therefore check for nullity rather than having a separate "success" parameter.
 private void PostProcess <TResponse>(AffinityConfig affinityConfig, ChannelRef channelRef, string boundKey, TResponse response)
 {
     channelRef.ActiveStreamCountDecr();
     // Process BIND or UNBIND if the method has affinity feature enabled, but only for successful calls.
     if (affinityConfig != null && response != null)
     {
         if (affinityConfig.Command == AffinityConfig.Types.Command.Bind)
         {
             Bind(channelRef, GetAffinityKeyFromProto(affinityConfig.AffinityKey, (IMessage)response));
         }
         else if (affinityConfig.Command == AffinityConfig.Types.Command.Unbind)
         {
             Unbind(boundKey);
         }
     }
 }
示例#3
0
        private Tuple <ChannelRef, string> PreProcess <TRequest>(AffinityConfig affinityConfig, TRequest request)
        {
            // Gets the affinity bound key if required in the request method.
            string boundKey = null;

            if (affinityConfig != null)
            {
                if (affinityConfig.Command == AffinityConfig.Types.Command.Bound ||
                    affinityConfig.Command == AffinityConfig.Types.Command.Unbind)
                {
                    boundKey = GetAffinityKeyFromProto(affinityConfig.AffinityKey, (IMessage)request);
                }
            }
            ChannelRef channelRef = GetChannelRef(boundKey);

            channelRef.ActiveStreamCountIncr();
            return(new Tuple <ChannelRef, string>(channelRef, boundKey));
        }