Example #1
0
        public IThreadSubscriptionBuilder <TPayload> Invoke(ISubscriptionHandler <TPayload> handler)
        {
            Assert.ArgumentNotNull(handler, nameof(handler));

            ValidateDoesNotHaveAction();
            _actionReference = new SubscriptionHandlerActionReference <TPayload>(handler);
            return(this);
        }
        public ThreadPoolThreadSubscription(IWorkerPool workerPool, ISubscriberReference <TPayload> action)
        {
            Assert.ArgumentNotNull(workerPool, nameof(workerPool));
            Assert.ArgumentNotNull(action, nameof(action));

            _workerPool = workerPool;
            _action     = action;
        }
        public SpecificThreadPubSubSubscription(ISubscriberReference <TPayload> action, int threadId, IWorkerPool workerPool)
        {
            Assert.ArgumentNotNull(action, nameof(action));
            Assert.ArgumentNotNull(workerPool, nameof(workerPool));

            _action     = action;
            _threadId   = threadId;
            _workerPool = workerPool;
        }
Example #4
0
        public IThreadSubscriptionBuilder <TPayload> InvokeEnvelope(Action <Envelope <TPayload> > action, bool useWeakReferences = false)
        {
            Assert.ArgumentNotNull(action, nameof(action));

            ValidateDoesNotHaveAction();
            var reference = CreateActionReference(action, useWeakReferences);

            _actionReference = reference;
            return(this);
        }
Example #5
0
        public IThreadSubscriptionBuilder <TPayload> ActivateAndInvoke <TService>(Func <TPayload, TService> createService, Action <TService, TPayload> handler, bool cacheService = true)
            where TService : class
        {
            Assert.ArgumentNotNull(handler, nameof(handler));
            Assert.ArgumentNotNull(createService, nameof(createService));

            ValidateDoesNotHaveAction();

            _actionReference = new ActivatedSubscriberReference <TPayload, TService>(createService, handler, cacheService);
            return(this);
        }
Example #6
0
        private ISubscription <TPayload> CreateBaseSubscription(ISubscriberReference <TPayload> actionReference, DispatchThreadType dispatchType, int threadId)
        {
            switch (dispatchType)
            {
            case DispatchThreadType.NoPreference:
                return(new AnyThreadPubSubSubscription <TPayload>(actionReference, _workerPool));

            case DispatchThreadType.AnyWorkerThread:
                return(new AnyThreadPubSubSubscription <TPayload>(actionReference, _workerPool));

            case DispatchThreadType.SpecificThread:
                return(new SpecificThreadPubSubSubscription <TPayload>(actionReference, threadId, _workerPool));

            case DispatchThreadType.ThreadpoolThread:
                return(new ThreadPoolThreadSubscription <TPayload>(_workerPool, actionReference));

            case DispatchThreadType.Immediate:
                return(new ImmediatePubSubSubscription <TPayload>(actionReference));

            default:
                return(new AnyThreadPubSubSubscription <TPayload>(actionReference, _workerPool));
            }
        }
Example #7
0
 public PublishEventThreadAction(ISubscriberReference <TPayload> action, Envelope <TPayload> message)
 {
     _action  = action;
     _message = message;
 }
Example #8
0
 public IThreadSubscriptionBuilder <TPayload> UseCustomSubscriber(ISubscriberReference <TPayload> subscriber)
 {
     Assert.ArgumentNotNull(subscriber, nameof(subscriber));
     _actionReference = subscriber;
     return(this);
 }
Example #9
0
        public ImmediatePubSubSubscription(ISubscriberReference <TPayload> action)
        {
            Assert.ArgumentNotNull(action, nameof(action));

            _action = action;
        }