Exemple #1
0
        private static IServiceRemotingMessageHandler CreateHandler(ActorService actorService, bool switchOperationContext)
        {
            IServiceRemotingMessageHandler
                messageHandler = new CorrelatingRemotingMessageHandler(actorService, switchOperationContext);

            return(messageHandler);
        }
Exemple #2
0
        public static ServiceInstanceListener CreateCorrelatingServiceInstanceListener(this StatelessService service,
                                                                                       IService serviceImplementation,
                                                                                       string listenerName = "")
        {
            var handler = new CorrelatingRemotingMessageHandler(service.Context, serviceImplementation);

            var listener = new ServiceInstanceListener(c => new FabricTransportServiceRemotingListener(c, handler));

            return(listener);
        }
        public static ServiceInstanceListener CreateCorrelatingServiceInstanceListener <TServiceInterface>(this StatelessService service,
                                                                                                           IService serviceImplementation,
                                                                                                           string listenerName = "",
                                                                                                           Action <CallSummary> raiseSummary = null)
        {
            var handler = new CorrelatingRemotingMessageHandler(L.G <TServiceInterface>(), service.Context, serviceImplementation, raiseSummary);

            var listener = new ServiceInstanceListener(c => new FabricTransportServiceRemotingListener(c, handler), listenerName);

            return(listener);
        }
Exemple #4
0
        public static ServiceReplicaListener CreateCorrelatingReplicaListener(this StatefulService service,
                                                                              IService serviceImplementation,
                                                                              string listenerName    = "",
                                                                              bool listenOnSecondary = false)
        {
            var handler = new CorrelatingRemotingMessageHandler(service.Context, serviceImplementation);

            var listener = new ServiceReplicaListener(c => new FabricTransportServiceRemotingListener(c, handler));

            return(listener);
        }
Exemple #5
0
        private static IServiceRemotingMessageHandler CreateHandler(object serviceInstance, ServiceContext context, bool switchOperationContext)
        {
            if (!(serviceInstance is IService))
            {
                throw new ArgumentException($"service must impelement {typeof(IService).FullName} interface");
            }

            IServiceRemotingMessageHandler
                messageHandler = new CorrelatingRemotingMessageHandler(context, (IService)serviceInstance, switchOperationContext);

            return(messageHandler);
        }
Exemple #6
0
        protected override IEnumerable <ServiceReplicaListener> CreateServiceReplicaListeners()
        {
            //collect base types where actor attribute can be defined
            var typeList = new List <Type> {
                ActorTypeInformation.ImplementationType
            };

            typeList.AddRange(ActorTypeInformation.InterfaceTypes);

            //get provider attribute that can override listener endpoints
            ActorRemotingProviderAttribute provider = ActorHelper.GetProvider(typeList);

            //create service remoting listeners the correct way
            var replicaListeners = new List <ServiceReplicaListener>();

            if (Helper.IsEitherRemotingV2(provider.RemotingListenerVersion))
            {
                foreach (KeyValuePair <string, Func <ActorService, IServiceRemotingListener> > remotingListener in provider.CreateServiceRemotingListeners())
                {
                    //create our own correlating message handler
                    var handler = new CorrelatingRemotingMessageHandler(
                        L.G(GetType()), //the most upstream type's log
                        this);

                    string listenerName = remotingListener.Key;
                    Func <ActorService, IServiceRemotingListener> createCommunicationListener = remotingListener.Value;

                    /*Func<ActorService, IServiceRemotingListener> debug = a =>
                     * {
                     * IServiceRemotingListener result = createCommunicationListener(a);
                     *
                     * return result;
                     * };*/

                    var listener = new ServiceReplicaListener(
                        c => new FabricTransportActorServiceRemotingListener(c, handler),
                        listenerName,
                        false);

                    /*var listener = new ServiceReplicaListener(
                     * //context => createCommunicationListener(this),
                     * context => debug(this),
                     * listenerName,
                     * false);*/

                    replicaListeners.Add(listener);
                }
            }

            return(replicaListeners);
        }