/// <summary> /// Use this pipeline 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">A description of what the channel is used for.</param> /// <param name="partitions">The supported partition levels for the channel. If null, this will be set to Priority 0 and 1.</param> /// <param name="boundaryLoggingEnabled">Use this flag to override the default boundary logging settings for the Microservice.</param> /// <param name="resourceProfiles">The resource profiles that should be used in the polling logic to reduce or stop incoming messages.</param> /// <param name="internalOnly">Set this flag to true if you don't wish to attach any external listeners to this channel, i.e. internal only.</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 IPipelineChannelIncoming <P> AddChannelIncoming <P>(this P pipeline , string channelId , string description = null , IEnumerable <ListenerPartitionConfig> partitions = null , bool?boundaryLoggingEnabled = null , IEnumerable <ResourceProfile> resourceProfiles = null , bool internalOnly = false , Action <IPipelineChannelIncoming <P>, Channel> assign = null , bool autosetPartition01 = true ) where P : IPipeline { var channel = pipeline.ToMicroservice().Communication.RegisterChannel( new Channel(channelId, ChannelDirection.Incoming, description, boundaryLoggingEnabled, internalOnly)); if (partitions == null && autosetPartition01) { partitions = ListenerPartitionConfig.Init(0, 1); } channel.Partitions = partitions?.ToList(); if (resourceProfiles != null) { channel.ResourceProfiles = resourceProfiles?.ToList(); } var cpipe = new ChannelPipelineIncoming <P>(pipeline, channel); assign?.Invoke(cpipe, cpipe.Channel); return(cpipe); }
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); }
/// <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); }
public static ChannelPipelineIncoming AssignPriorityPartition(this ChannelPipelineIncoming pipeline, params int[] init) { ListenerPartitionConfig.Init(init).ForEach((p) => AddPriorityPartition <ListenerPartitionConfig>(pipeline, p)); return(pipeline); }