Example #1
0
        /// <inheritdoc />
        internal override async Task <TrafficResult> InterPreCall(TMsg context)
        {
            var pushRes = await _pusher.Publish(PipeCode, context);

            return(pushRes
                ? new TrafficResult(SignalFlag.Green_Pass, string.Empty, string.Empty)
                : new TrafficResult(SignalFlag.Red_Block, PipeCode, $"({this.GetType().Name})推送消息失败!"));
        }
Example #2
0
        public Task Watch(WatchDataItem data)
        {
            if (_publisher != null)
            {
                return(_publisher.Publish(_dataFlowKey, data));
            }

            _watchDataQueue.Post(data);
            return(Task.CompletedTask);
        }
Example #3
0
        internal override async Task <TrafficResult <Empty, TMsg> > InterProcessPackage(TMsg context)
        {
            var msgKey = GeneratePushKey(context);

            if (string.IsNullOrEmpty(msgKey))
            {
                return(new TrafficResult <Empty, TMsg>(SignalFlag.Green_Pass, string.Empty, string.Empty, Empty.Default,
                                                       context));
            }
            return((await _pusher.Publish(msgKey, context))
                ? new TrafficResult <Empty, TMsg>(SignalFlag.Green_Pass, string.Empty, string.Empty, Empty.Default, context)
                : new TrafficResult <Empty, TMsg>(SignalFlag.Red_Block, PipeCode, $"{this.GetType().Name}发布消息失败!", Empty.Default, context));
        }
Example #4
0
        public async Task Publish <TEvent>(TEvent @event)
            where TEvent : IEvent <TProducer>
        {
            var type = typeof(TEvent);

            if (!_routeCollection.TryGetValue(type, out OutputRoute route))
            {
                throw new Exception($"Route for type \"{type.FullName}\" has not been found");
            }

            await _publisher.Publish(
                route,
                new EventMetadata(type.AssemblyQualifiedName, typeof(TProducer).Name, "0.0.1"),
                @event);
        }