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);
        }
        public static ChannelPipelineOutgoing AssignPriorityPartition(this ChannelPipelineOutgoing pipeline, Func <IEnvironmentConfiguration, Channel, SenderPartitionConfig> creator)
        {
            var config = creator(pipeline.Pipeline.Configuration, pipeline.Channel);

            AddPriorityPartition <SenderPartitionConfig>(pipeline, config);
            return(pipeline);
        }
Example #3
0
        public static MicroservicePipeline AddCommand <C>(this MicroservicePipeline pipeline
                                                          , C command
                                                          , Action <C> assignment = null
                                                          , ChannelPipelineIncoming channelIncoming = null
                                                          , ChannelPipelineOutgoing channelResponse = null
                                                          , ChannelPipelineIncoming channelMasterJobNegotiationIncoming = null
                                                          , ChannelPipelineOutgoing channelMasterJobNegotiationOutgoing = null
                                                          )
            where C : ICommand
        {
            if (channelIncoming != null && command.ChannelIdAutoSet)
            {
                command.ChannelId = channelIncoming.Channel.Id;
            }

            if (channelResponse != null && command.ResponseChannelIdAutoSet)
            {
                command.ResponseChannelId = channelResponse.Channel.Id;
            }

            if (channelMasterJobNegotiationIncoming != null && command.MasterJobNegotiationChannelIdAutoSet)
            {
                command.MasterJobNegotiationChannelIdIncoming = channelMasterJobNegotiationIncoming.Channel.Id;
            }

            if (channelMasterJobNegotiationOutgoing != null && command.MasterJobNegotiationChannelIdAutoSet)
            {
                command.MasterJobNegotiationChannelIdOutgoing = channelMasterJobNegotiationOutgoing.Channel.Id;
            }

            assignment?.Invoke(command);
            pipeline.Service.RegisterCommand(command);
            return(pipeline);
        }
Example #4
0
        public static ChannelPipelineIncoming AddCommand <C>(this ChannelPipelineIncoming cpipe
                                                             , Func <IEnvironmentConfiguration, C> creator
                                                             , Action <C> assignment = null
                                                             , ChannelPipelineOutgoing channelResponse = null
                                                             , ChannelPipelineIncoming channelMasterJobNegotiationIncoming = null
                                                             , ChannelPipelineOutgoing channelMasterJobNegotiationOutgoing = null
                                                             )
            where C : ICommand
        {
            cpipe.Pipeline.AddCommand(creator, assignment, cpipe, channelResponse, channelMasterJobNegotiationIncoming, channelMasterJobNegotiationOutgoing);

            return(cpipe);
        }
Example #5
0
        public static ChannelPipelineIncoming AddCommand <C>(this ChannelPipelineIncoming cpipe
                                                             , C command
                                                             , Action <C> assignment = null
                                                             , ChannelPipelineOutgoing channelResponse = null
                                                             , ChannelPipelineIncoming channelMasterJobNegotiationIncoming = null
                                                             , ChannelPipelineOutgoing channelMasterJobNegotiationOutgoing = null
                                                             )
            where C : ICommand
        {
            cpipe.Pipeline.AddCommand(command, assignment, cpipe, channelResponse, channelMasterJobNegotiationIncoming, channelMasterJobNegotiationOutgoing);

            return(cpipe);
        }
Example #6
0
        public static MicroservicePipeline AddCommand <C>(this MicroservicePipeline pipeline
                                                          , Func <IEnvironmentConfiguration, C> creator
                                                          , Action <C> assignment = null
                                                          , ChannelPipelineIncoming channelIncoming = null
                                                          , ChannelPipelineOutgoing channelResponse = null
                                                          , ChannelPipelineIncoming channelMasterJobNegotiationIncoming = null
                                                          , ChannelPipelineOutgoing channelMasterJobNegotiationOutgoing = null
                                                          )
            where C : ICommand
        {
            var command = creator(pipeline.Configuration);

            return(pipeline.AddCommand(command, assignment, channelIncoming, channelResponse, channelMasterJobNegotiationIncoming));
        }
Example #7
0
        public static ChannelPipelineOutgoing AttachSender <S>(this ChannelPipelineOutgoing cpipe
                                                               , Func <IEnvironmentConfiguration, S> creator
                                                               , Action <S> action             = null
                                                               , bool setFromChannelProperties = true)
            where S : ISender
        {
            var sender = creator(cpipe.Pipeline.Configuration);

            action?.Invoke(sender);

            cpipe.AttachSender(sender, setFromChannelProperties);

            return(cpipe);
        }
        public static ChannelPipelineOutgoing AddChannelOutgoing(this MicroservicePipeline pipeline
                                                                 , string channelId
                                                                 , string description = null
                                                                 , IEnumerable <SenderPartitionConfig> partitions = null
                                                                 , IBoundaryLogger bLogger = null
                                                                 , bool internalOnly       = false
                                                                 , Action <ChannelPipelineOutgoing, Channel> assign = null
                                                                 )
        {
            var channel = pipeline.Service.RegisterChannel(new Channel(channelId, ChannelDirection.Outgoing, description, bLogger, internalOnly));

            if (partitions != null)
            {
                channel.Partitions = partitions.ToList();
            }

            var cpipe = new ChannelPipelineOutgoing(pipeline, channel);

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

            return(cpipe);
        }
Example #9
0
        public static ChannelPipelineOutgoing AttachSender(this ChannelPipelineOutgoing cpipe
                                                           , ISender sender
                                                           , bool setFromChannelProperties = true)
        {
            if (cpipe.Channel.InternalOnly)
            {
                throw new ChannelInternalOnlyException(cpipe.Channel.Id, cpipe.Channel.Direction);
            }

            if (setFromChannelProperties && sender.ChannelId != cpipe.Channel.Id)
            {
                throw new ChannelIdMismatchException(cpipe.Channel.Id, cpipe.Channel.Direction, sender.ChannelId);
            }

            if (setFromChannelProperties)
            {
                sender.BoundaryLogger     = cpipe.Channel.BoundaryLogger;
                sender.PriorityPartitions = cpipe.Channel.Partitions.Cast <SenderPartitionConfig>().ToList();
            }

            cpipe.Pipeline.Service.RegisterSender(sender);

            return(cpipe);
        }
 public static ChannelPipelineOutgoing AssignPriorityPartition(this ChannelPipelineOutgoing pipeline, IEnumerable <SenderPartitionConfig> config)
 {
     config?.ForEach((p) => pipeline.AssignPriorityPartition(p));
     return(pipeline);
 }
        public static ChannelPipelineOutgoing AssignPriorityPartition(this ChannelPipelineOutgoing pipeline, params int[] init)
        {
            SenderPartitionConfig.Init(init).ForEach((p) => AddPriorityPartition <SenderPartitionConfig>(pipeline, p));

            return(pipeline);
        }
        //Outgoing
        public static ChannelPipelineOutgoing AssignPriorityPartition(this ChannelPipelineOutgoing pipeline, SenderPartitionConfig config)
        {
            AddPriorityPartition <SenderPartitionConfig>(pipeline, config);

            return(pipeline);
        }