Ejemplo n.º 1
0
        public static IPipelineChannelOutgoing <P> AddChannelOutgoing <P>(this P pipeline
                                                                          , string channelId
                                                                          , string description = null
                                                                          , IEnumerable <SenderPartitionConfig> partitions = null
                                                                          , bool?boundaryLoggingEnabled = null
                                                                          , bool internalOnly           = false
                                                                          , Action <IPipelineChannelOutgoing <P>, Channel> assign = null
                                                                          , bool autosetPartition01 = true
                                                                          )
            where P : IPipeline
        {
            var channel = pipeline.ToMicroservice().Communication.RegisterChannel(
                new Channel(channelId, ChannelDirection.Outgoing, description, boundaryLoggingEnabled, internalOnly));

            if (partitions == null && autosetPartition01)
            {
                partitions = SenderPartitionConfig.Init(0, 1);
            }

            channel.Partitions = partitions?.ToList();

            var cpipe = new ChannelPipelineOutgoing <P>(pipeline, channel);

            assign?.Invoke(cpipe, cpipe.Channel);

            return(cpipe);
        }
 /// <summary>
 /// This is the default constructor for the Azure service bus sender.
 /// </summary>
 public QueueEventSource() : base()
 {
     mJsonSerializer = new JsonSerializer {
         TypeNameHandling = TypeNameHandling.Auto
     };
     PriorityPartitions = SenderPartitionConfig.Init(1).ToList();
 }
        public static C AttachPriorityPartition <C>(this C pipeline, params int[] init)
            where C : IPipelineChannel
        {
            if (pipeline is IPipelineChannelIncoming)
            {
                ListenerPartitionConfig.Init(init).ForEach((p) => AttachPriorityPartition <ListenerPartitionConfig>(pipeline, p));
            }
            else if (pipeline is IPipelineChannelOutgoing)
            {
                SenderPartitionConfig.Init(init).ForEach((p) => AttachPriorityPartition <SenderPartitionConfig>(pipeline, p));
            }
            else
            {
                throw new ArgumentOutOfRangeException("AttachPriorityPartition unexpected partition type.");
            }

            return(pipeline);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// use this command to add a channel to a Microservice.
        /// </summary>
        /// <param name="pipeline">The pipeline.</param>
        /// <param name="channelId">The channel id.</param>
        /// <param name="description"></param>
        /// <param name="partitions"></param>
        /// <param name="boundaryLoggingEnabled"></param>
        /// <param name="resourceProfiles"></param>
        /// <param name="internalOnly"></param>
        /// <param name="assign"></param>
        /// <param name="autosetPartition01">This method automatically sets the default priority 0 and 1 partitions for the channel.</param>
        /// <returns>The original pipeline.</returns>
        public static IPipelineChannelBroadcast <P> AddChannelBroadcast <P>(this P pipeline
                                                                            , string channelId
                                                                            , string description = null
                                                                            , IEnumerable <ListenerPartitionConfig> partitionsListener = null
                                                                            , IEnumerable <SenderPartitionConfig> partitionsSender     = null
                                                                            , bool?boundaryLoggingEnabled = null
                                                                            , IEnumerable <ResourceProfile> resourceProfiles = null
                                                                            , bool internalOnly = false
                                                                            , Action <IPipelineChannelBroadcast <P> > assign = null
                                                                            , bool autosetPartition2 = true
                                                                            )
            where P : IPipeline
        {
            var channelListener = pipeline.ToMicroservice().Communication.RegisterChannel(
                new Channel(channelId, ChannelDirection.Incoming, description, boundaryLoggingEnabled, internalOnly));

            var channelSender = pipeline.ToMicroservice().Communication.RegisterChannel(
                new Channel(channelId, ChannelDirection.Outgoing, description, boundaryLoggingEnabled, internalOnly));

            if (partitionsListener == null && autosetPartition2)
            {
                partitionsListener = ListenerPartitionConfig.Init(2);
            }

            if (partitionsSender == null && autosetPartition2)
            {
                partitionsSender = SenderPartitionConfig.Init(2);
            }

            channelListener.Partitions = partitionsListener?.ToList();
            channelSender.Partitions   = partitionsSender?.ToList();

            if (resourceProfiles != null)
            {
                channelListener.ResourceProfiles = resourceProfiles?.ToList();
            }

            var cpipe = new ChannelPipelineBroadcast <P>(pipeline, channelListener, channelSender);

            assign?.Invoke(cpipe);

            return(cpipe);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// This is the default constructor for the Azure service bus sender.
 /// </summary>
 public AzureSBEventHubSender() : base()
 {
     SenderPriorityPartitions = SenderPartitionConfig.Init(1).ToList();
 }
        public static ChannelPipelineOutgoing AssignPriorityPartition(this ChannelPipelineOutgoing pipeline, params int[] init)
        {
            SenderPartitionConfig.Init(init).ForEach((p) => AddPriorityPartition <SenderPartitionConfig>(pipeline, p));

            return(pipeline);
        }