/// <summary> /// This extension adds the inline command to the pipeline /// </summary> /// <typeparam name="P">The pipeline type.</typeparam> /// <param name="pipeline">The pipeline.</param> /// <param name="commandFunction">The command function.</param> /// <param name="header">The destination fragment</param> /// <param name="referenceId">The optional command reference id</param> /// <param name="startupPriority">The command startup priority.</param> /// <param name="channelIncoming">The incoming channel. This is optional if you pass channel information in the header.</param> /// <param name="autoCreateChannel">Set this to true if you want the incoming channel created if it does not exist. The default is true.</param> /// <returns>Returns the pipeline.</returns> public static P AddCommand <P>(this P pipeline , Func <CommandMethodRequestContext, Task> commandFunction , ServiceMessageHeaderFragment header , string referenceId = null , int startupPriority = 100 , IPipelineChannelIncoming <P> channelIncoming = null , bool autoCreateChannel = true ) where P : IPipeline { ServiceMessageHeader location; if (header is ServiceMessageHeader) { location = (ServiceMessageHeader)header; } else { if (channelIncoming == null) { throw new ChannelIncomingMissingException(); } location = (channelIncoming.Channel.Id, header); } var command = new CommandMethodInline(location, commandFunction, referenceId); pipeline.AddCommand(command, startupPriority, null, channelIncoming); return(pipeline); }
private void ChannelInConfigure(IPipelineChannelIncoming <MicroservicePipeline> inPipe) { inPipe .AttachResourceProfile("TrackIt") //.AppendBoundaryLogger(new MemoryBoundaryLogger(), (p, bl) => bLogger = bl) ; }
/// <summary> /// This extension method is used to add a command to the Microservice. /// </summary> /// <typeparam name="P">The pipeline type.</typeparam> /// <typeparam name="C">The command type.</typeparam> /// <param name="pipeline">The pipeline.</param> /// <param name="command">The command to add.</param> /// <param name="startupPriority">The optional start up priority. The default is 100.</param> /// <param name="assign">The command assignment action.</param> /// <param name="channelIncoming">The optional request channel.</param> /// <param name="channelResponse">The optional response channel.</param> /// <returns>Returns the pipeline.</returns> public static P AddCommand <P, C>(this P pipeline , C command , int startupPriority = 100 , Action <C> assign = null , IPipelineChannelIncoming <P> channelIncoming = null , IPipelineChannelOutgoing <P> channelResponse = null ) where P : IPipeline where C : ICommand { command.StartupPriority = startupPriority; if (channelIncoming != null && command.ChannelIdAutoSet) { command.ChannelId = channelIncoming.Channel.Id; } if (channelResponse != null && command.ResponseChannelIdAutoSet) { command.ResponseChannelId = channelResponse.Channel.Id; } assign?.Invoke(command); pipeline.Service.Commands.Register(command); return(pipeline); }
/// <summary> /// This extension method attaches a memory persistence command to the incoming pipeline. /// </summary> /// <typeparam name="P">The incoming channel type.</typeparam> /// <typeparam name="K">The equatable key type.</typeparam> /// <typeparam name="E">The entity type.</typeparam> /// <param name="pipeline">The pipeline.</param> /// <param name="keyMaker">This function creates a key of type K from an entity of type E</param> /// <param name="keyDeserializer">The entity key deserializer.</param> /// <param name="cpipe">The incoming channel to listen for requests.</param> /// <param name="startupPriority">The command start-up priority.</param> /// <param name="entityName">The entity name to be used in the collection. By default this will be set through reflection.</param> /// <param name="versionPolicy">The version policy. This is needed if you wish to support optimistic locking for updates.</param> /// <param name="defaultTimeout">The default timeout. This is used for testing to simulate timeouts.</param> /// <param name="persistenceRetryPolicy">The retry policy. This is used for testing purposes.</param> /// <param name="resourceProfile">The resource profile.</param> /// <param name="cacheManager">The cache manager.</param> /// <param name="referenceMaker">The reference maker. This is used for entities that support read by reference.</param> /// <param name="referenceHashMaker">The reference hash maker. This is used for fast lookup.</param> /// <param name="keySerializer">The key serializer function.</param> /// <param name="prePopulate">The optional pre-population collection.</param> /// <returns>The pipeline.</returns> public static P AddPersistenceManagerHandlerMemory <P, K, E>(this P pipeline , Func <E, K> keyMaker , Func <string, K> keyDeserializer , IPipelineChannelIncoming <P> cpipe , int startupPriority = 100 , string entityName = null , VersionPolicy <E> versionPolicy = null , TimeSpan?defaultTimeout = default(TimeSpan?) , PersistenceRetryPolicy persistenceRetryPolicy = null , ResourceProfile resourceProfile = null , ICacheManager <K, E> cacheManager = null , Func <E, IEnumerable <Tuple <string, string> > > referenceMaker = null , Func <Tuple <string, string>, string> referenceHashMaker = null , Func <K, string> keySerializer = null , IEnumerable <KeyValuePair <K, E> > prePopulate = null ) where P : IPipeline where K : IEquatable <K> { PersistenceManagerHandlerMemory <K, E> pm = null; return(pipeline.AddPersistenceManagerHandlerMemory(keyMaker, keyDeserializer, cpipe, out pm , startupPriority , entityName: entityName , versionPolicy: versionPolicy , defaultTimeout: defaultTimeout , persistenceRetryPolicy: persistenceRetryPolicy , resourceProfile: resourceProfile , cacheManager: cacheManager , referenceMaker: referenceMaker , referenceHashMaker: referenceHashMaker , keySerializer: keySerializer , prePopulate: prePopulate)); }
/// <summary> /// This method adds the appropriate persistence command. /// </summary> /// <param name="cpipe">The pipeline.</param> static void ServerCommunicationSet(IPipelineChannelIncoming <MicroservicePipeline> cpipe) { var config = cpipe.ToConfiguration(); switch (sSettings.CommunicationType) { case CommunicationOptions.Local: break; case CommunicationOptions.Tcp: cpipe.AttachTcpTlsListener(); break; case CommunicationOptions.Tls: break; case CommunicationOptions.AzureServiceBus: cpipe.AttachAzureServiceBusTopicListener(); break; case CommunicationOptions.AzureBlobQueue: break; default: throw new NotSupportedException(); } }
private void ChannelInConfigure(IPipelineChannelIncoming <MicroservicePipeline> inPipe) { inPipe .AttachResourceProfile("TrackIt", "Track2", ("Track3", false)) //.AppendBoundaryLogger(new MemoryBoundaryLogger(), (p, bl) => bLogger = bl) ; calloutIn = true; }
/// <summary> /// This extension method attaches a memory persistence command to the incoming pipeline. /// </summary> /// <typeparam name="P">The incoming channel type.</typeparam> /// <typeparam name="K">The equatable key type.</typeparam> /// <typeparam name="E">The entity type.</typeparam> /// <param name="pipeline">The pipeline.</param> /// <param name="keyMaker">This function creates a key of type K from an entity of type E</param> /// <param name="keyDeserializer">The entity key deserializer.</param> /// <param name="cpipe">The incoming channel to listen for requests.</param> /// <param name="credentials">This is the optional azure storage credentials. /// If this is not supplied, the method will try and extract this from configuration using the StorageAccountName and StorageAccountAccessKey keys.</param> /// <param name="startupPriority">The command start-up priority.</param> /// <param name="entityName">The entity name to be used in the collection. By default this will be set through reflection.</param> /// <param name="versionPolicy">The version policy. This is needed if you wish to support optimistic locking for updates.</param> /// <param name="defaultTimeout">The default timeout. This is used for testing to simulate timeouts.</param> /// <param name="persistenceRetryPolicy">The retry policy. This is used for testing purposes.</param> /// <param name="resourceProfile">The resource profile.</param> /// <param name="referenceMaker">The reference maker. This is used for entities that support read by reference.</param> /// <param name="keySerializer">The key serializer function.</param> /// <returns>The pipeline.</returns> public static P AddPersistenceManagerDocumentDbSdk <P, K, E>(this P pipeline , Func <E, K> keyMaker , Func <string, K> keyDeserializer , IPipelineChannelIncoming <P> cpipe , DocumentDbConnection connection = null , string database = null , int startupPriority = 100 , string entityName = null , VersionPolicy <E> versionPolicy = null , TimeSpan?defaultTimeout = default(TimeSpan?) , PersistenceRetryPolicy persistenceRetryPolicy = null , ResourceProfile resourceProfile = null , Func <E, IEnumerable <Tuple <string, string> > > referenceMaker = null , Func <K, string> keySerializer = null ) where P : IPipeline where K : IEquatable <K> { if (keyMaker == null) { throw new ArgumentNullException("keyMaker", $"keyMaker cannot be null in {nameof(AddPersistenceManagerDocumentDbSdk)}"); } if (keyDeserializer == null) { throw new ArgumentNullException("keyDeserializer", $"keyDeserializer cannot be null in {nameof(AddPersistenceManagerDocumentDbSdk)}"); } if (cpipe == null) { throw new ArgumentNullException("cpipe", $"cpipe cannot be null in {nameof(AddPersistenceManagerDocumentDbSdk)}"); } if (connection == null) { connection = pipeline.Configuration.DocDBConnection(true); } if (database == null) { database = pipeline.Configuration.DocDBDatabaseName(false); } var pm = new PersistenceMessageHandlerDocumentDbSdk <K, E>(connection, database, keyMaker, keyDeserializer , entityName: entityName , versionPolicy: versionPolicy , defaultTimeout: defaultTimeout , persistenceRetryPolicy: persistenceRetryPolicy , resourceProfile: resourceProfile , referenceMaker: referenceMaker , keySerializer: keySerializer ); pipeline.AddCommand(pm, startupPriority, channelIncoming: cpipe); return(pipeline); }
/// <summary> /// This extension method is used to add a command to the Microservice. /// </summary> /// <typeparam name="P">The pipeline type.</typeparam> /// <typeparam name="C">The command type.</typeparam> /// <param name="pipeline">The pipeline.</param> /// <param name="startupPriority">The optional start up priority. The default is 100.</param> /// <param name="assign">The command assignment action.</param> /// <param name="channelIncoming">The optional request channel.</param> /// <param name="channelResponse">The optional response channel.</param> /// <returns>Returns the pipeline.</returns> public static P AddCommand <P, C>(this P pipeline , int startupPriority = 100 , Action <C> assign = null , IPipelineChannelIncoming <P> channelIncoming = null , IPipelineChannelOutgoing <P> channelResponse = null ) where P : IPipeline where C : ICommand, new() { return(pipeline.AddCommand(new C(), startupPriority, assign, channelIncoming, channelResponse)); }
static void PersistenceCommandSet(IPipelineChannelIncoming <MicroservicePipeline> cpipe) { var config = cpipe.ToConfiguration(); switch (sContext.PersistenceType) { case PersistenceOptions.Sql: cpipe.AttachCommand(new PersistenceMondayMorningBluesSql(config.SqlConnection(), MondayMorningBluesHelper.VersionPolicyHelper)); break; case PersistenceOptions.Blob: cpipe.AttachPersistenceManagerAzureBlobStorage( (MondayMorningBlues k) => k.Id , (s) => new Guid(s) , keySerializer: (g) => g.ToString("N").ToUpperInvariant() , versionPolicy: MondayMorningBluesHelper.VersionPolicyHelper , referenceMaker: MondayMorningBluesHelper.ToReferences ); break; case PersistenceOptions.DocumentDb: cpipe.AttachPersistenceManagerDocumentDb( (MondayMorningBlues k) => k.Id , (s) => new Guid(s) , versionPolicy: MondayMorningBluesHelper.VersionPolicyHelper , referenceMaker: MondayMorningBluesHelper.ToReferences ); break; case PersistenceOptions.DocumentDbSdk: cpipe.AttachPersistenceManagerDocumentDbSdk( (MondayMorningBlues k) => k.Id , (s) => new Guid(s) , versionPolicy: MondayMorningBluesHelper.VersionPolicyHelper , referenceMaker: MondayMorningBluesHelper.ToReferences ); break; case PersistenceOptions.Memory: cpipe.AttachPersistenceManagerHandlerMemory( (MondayMorningBlues k) => k.Id , (s) => new Guid(s) , versionPolicy: MondayMorningBluesHelper.VersionPolicyHelper , referenceMaker: MondayMorningBluesHelper.ToReferences); break; case PersistenceOptions.RedisCache: cpipe.AttachPersistenceManagerRedisCache( (MondayMorningBlues k) => k.Id , (s) => new Guid(s) , versionPolicy: MondayMorningBluesHelper.VersionPolicyHelper , referenceMaker: MondayMorningBluesHelper.ToReferences); break; } }
public static P AddCommandUnity <P, I, C>(this P pipeline , Func <IEnvironmentConfiguration, C> creator , int startupPriority = 100 , Action <C> assign = null , IPipelineChannelIncoming <P> channelIncoming = null , IPipelineChannelOutgoing <P> channelResponse = null ) where P : IPipelineWebApiUnity where C : I, ICommand { return(pipeline.AddCommandUnity <P, I, C>(creator(pipeline.Configuration) , startupPriority, assign, channelIncoming, channelResponse)); }
/// <summary> /// This extension method attaches a memory persistence command to the incoming pipeline. /// </summary> /// <typeparam name="P">The incoming channel type.</typeparam> /// <typeparam name="K">The equatable key type.</typeparam> /// <typeparam name="E">The entity type.</typeparam> /// <param name="pipeline">The pipeline.</param> /// <param name="keyMaker">This function creates a key of type K from an entity of type E</param> /// <param name="keyDeserializer">The entity key deserializer.</param> /// <param name="cpipe">The incoming channel to listen for requests.</param> /// <param name="pm">An output parameter for the persistence manager.</param> /// <param name="startupPriority">The command start-up priority.</param> /// <param name="entityName">The entity name to be used in the collection. By default this will be set through reflection.</param> /// <param name="versionPolicy">The version policy. This is needed if you wish to support optimistic locking for updates.</param> /// <param name="defaultTimeout">The default timeout. This is used for testing to simulate timeouts.</param> /// <param name="persistenceRetryPolicy">The retry policy. This is used for testing purposes.</param> /// <param name="resourceProfile">The resource profile.</param> /// <param name="cacheManager">The cache manager.</param> /// <param name="referenceMaker">The reference maker. This is used for entities that support read by reference.</param> /// <param name="referenceHashMaker">The reference hash maker. This is used for fast lookup.</param> /// <param name="keySerializer">The key serializer function.</param> /// <param name="prePopulate">The optional pre-population collection.</param> /// <returns>The pipeline.</returns> public static P AddPersistenceManagerHandlerMemory <P, K, E>(this P pipeline , Func <E, K> keyMaker , Func <string, K> keyDeserializer , IPipelineChannelIncoming <P> cpipe , out PersistenceManagerHandlerMemory <K, E> pm , int startupPriority = 100 , string entityName = null , VersionPolicy <E> versionPolicy = null , TimeSpan?defaultTimeout = default(TimeSpan?) , PersistenceRetryPolicy persistenceRetryPolicy = null , ResourceProfile resourceProfile = null , ICacheManager <K, E> cacheManager = null , Func <E, IEnumerable <Tuple <string, string> > > referenceMaker = null , Func <Tuple <string, string>, string> referenceHashMaker = null , Func <K, string> keySerializer = null , IEnumerable <KeyValuePair <K, E> > prePopulate = null ) where P : IPipeline where K : IEquatable <K> { if (keyMaker == null) { throw new ArgumentNullException("keyMaker", $"keyMaker cannot be null in {nameof(AddPersistenceManagerHandlerMemory)}"); } if (keyDeserializer == null) { throw new ArgumentNullException("keyDeserializer", $"keyDeserializer cannot be null in {nameof(AddPersistenceManagerHandlerMemory)}"); } if (cpipe == null) { throw new ArgumentNullException("cpipe", $"cpipe cannot be null in {nameof(AddPersistenceManagerHandlerMemory)}"); } pm = new PersistenceManagerHandlerMemory <K, E>(keyMaker, keyDeserializer , entityName: entityName , versionPolicy: versionPolicy , defaultTimeout: defaultTimeout , persistenceRetryPolicy: persistenceRetryPolicy , resourceProfile: resourceProfile , cacheManager: cacheManager , referenceMaker: referenceMaker , referenceHashMaker: referenceHashMaker , keySerializer: keySerializer , prePopulate: prePopulate); pipeline.AddCommand(pm, startupPriority, channelIncoming: cpipe); return(pipeline); }
/// <summary> /// This method adds a command initiator to the Microservice. /// </summary> /// <typeparam name="P">The pipeline type.</typeparam> /// <param name="pipeline">The pipeline.</param> /// <param name="command">The command initiator output.</param> /// <param name="startupPriority">The start up priority. The default is 90.</param> /// <param name="defaultRequestTimespan">The default request timespan.</param> /// <param name="channelIncoming">The incoming channel to attach the command initiator to.</param> /// <returns>The pipeline.</returns> public static P AddCommandInitiator <P>(this P pipeline , out CommandInitiator command , int startupPriority = 90 , TimeSpan?defaultRequestTimespan = null , IPipelineChannelIncoming <P> channelIncoming = null ) where P : IPipeline { command = new CommandInitiator(defaultRequestTimespan) { ResponseChannelId = channelIncoming.Channel.Id }; return(pipeline.AddCommand(command, startupPriority)); }
/// <summary> /// This extension adds the in-line command to the pipeline /// </summary> /// <typeparam name="P">The pipeline type.</typeparam> /// <param name="pipeline">The pipeline.</param> /// <param name="function">The command schedule function.</param> /// <param name="timerConfig">The schedule timer configuration.</param> /// <param name="referenceId">The optional command reference id</param> /// <param name="isLongRunning">Specifies whether the schedule will be long running.</param> /// <param name="startupPriority">The command start-up priority.</param> /// <param name="channelIncoming">The incoming channel. This is optional if you pass channel information in the header.</param> /// <returns>Returns the pipeline.</returns> public static P AddSchedule <P>(this P pipeline , Func <CommandScheduleInlineContext, Task> function , ScheduleTimerConfig timerConfig = null , string referenceId = null , bool isLongRunning = false , int startupPriority = 100 , IPipelineChannelIncoming <P> channelIncoming = null ) where P : IPipeline { var command = new CommandScheduleInline(function, timerConfig, referenceId, isLongRunning); pipeline.AddCommand(command, startupPriority, null, channelIncoming); return(pipeline); }
public static P AddCommandUnity <P, I, C>(this P pipeline , C command , int startupPriority = 100 , Action <C> assign = null , IPipelineChannelIncoming <P> channelIncoming = null , IPipelineChannelOutgoing <P> channelResponse = null ) where P : IPipelineWebApiUnity where C : I, ICommand { pipeline.AddCommand(command, startupPriority, assign, channelIncoming, channelResponse); pipeline.Unity.RegisterInstance <I>(command); return(pipeline); }
public static P AddCommand <P>(this P pipeline , Func <TransmissionPayload, List <TransmissionPayload>, IPayloadSerializationContainer, Task> commandFunction , ServiceMessageHeader header , string referenceId = null , int startupPriority = 100 , IPipelineChannelIncoming <P> channelIncoming = null , IPipelineChannelOutgoing <P> channelResponse = null ) where P : IPipeline { var command = new CommandInline(header, commandFunction, referenceId); pipeline.AddCommand(command, startupPriority, null, channelIncoming, channelResponse); return(pipeline); }
protected virtual IPipeline Pipeline() { var pipeline = new MicroservicePipeline(GetType().Name); pipeline .AddDebugMemoryDataCollector(out mCollector) .AddPayloadSerializerDefaultJson() .AddChannelIncoming("internalIn", internalOnly: true) .AttachCommand(mCommand) .CallOut((c) => cpipeIn = c) .Revert() .AddChannelOutgoing("internalOut", internalOnly: true, autosetPartition01: false) .AttachPriorityPartition(0, 1) .CallOut((c) => cpipeOut = c) .Revert() .AddChannelIncoming("internalInit", internalOnly: true) .AttachCommandInitiator(out mCommandInit); return(pipeline); }
private void IsFalseEx(IPipelineChannelIncoming <WebApiMicroservicePipeline> pipeEx) { }
public void Pipeline1() { try { var pipeline = new MicroservicePipeline("TestPipeline"); IPipelineChannelIncoming <MicroservicePipeline> cpipeIn = null; IPipelineChannelOutgoing <MicroservicePipeline> cpipeOut = null; PersistenceInternalService <Guid, Blah> persistence = null; PersistenceBlahMemory persistBlah = null; DebugMemoryDataCollector collector; int signalChange = 0; pipeline .AddDebugMemoryDataCollector(out collector) .AdjustPolicyTaskManager((t, c) => { t.ConcurrentRequestsMin = 1; t.ConcurrentRequestsMax = 4; }) .CallOut(ConfigureServiceRoot) .CallOut(CallOutDefault) .AddChannelIncoming("internalIn", internalOnly: true) .CallOut(ChannelInConfigure, (c) => true) .AttachCommand(new PersistenceBlahMemory(profile: "Blah"), assign: (p) => persistBlah = p) .AttachCommand(new PersistenceInternalService <Guid, Blah>(), assign: (c) => persistence = c, channelResponse: cpipeOut) .CallOut((c) => cpipeIn = c) .Revert() .AddChannelOutgoing("internalOut", internalOnly: true) .CallOut(ChannelOutConfigure, (c) => false) .CallOut((c) => cpipeOut = c) .Revert(); persistBlah.OnEntityChangeAction += ((o, e) => { signalChange++; }); pipeline.Start(); Guid cId = Guid.NewGuid(); var blah = new Blah { ContentId = cId, Message = "Hello", VersionId = Guid.NewGuid() }; var result = persistence.Create(blah).Result; Assert.IsTrue(result.IsSuccess); var result2 = persistence.Read(cId).Result; Assert.IsTrue(result2.IsSuccess); blah.VersionId = Guid.NewGuid(); var result3 = persistence.Update(blah).Result; Assert.IsTrue(result3.IsSuccess); var result4 = persistence.Delete(blah.ContentId).Result; Assert.IsTrue(result4.IsSuccess); Assert.IsTrue(signalChange == 3); Assert.IsTrue(calloutDefault.HasValue); Assert.IsTrue(calloutIn.HasValue); Assert.IsFalse(calloutOut.HasValue); pipeline.Stop(); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public void Pipeline2() { try { DebugMemoryDataCollector collector1, collector1a, collector2; CommandInitiator init = null; CommandInitiator init2 = null; IPipelineChannelIncoming <MicroservicePipeline> cpipeIn = null; IPipelineChannelOutgoing <MicroservicePipeline> cpipeOut = null; var fabric = new ManualFabricBridge(); var bridgeOut = new ManualCommunicationBridgeAgent(fabric, CommunicationBridgeMode.RoundRobin); var bridgeReturn = new ManualCommunicationBridgeAgent(fabric, CommunicationBridgeMode.Broadcast); //bridgeReturn.Agent.OnReceive += (o, e) => { if (e.Payload.Extent.Days == 42) init.ToString(); }; //bridgeReturn.Agent.OnException += (o, e) => { if (e.Payload.Extent.Days == 42) init.ToString(); }; var pClient = new MicroservicePipeline("Client"); var pClient2 = new MicroservicePipeline("Client2"); var pServer = new MicroservicePipeline("Server"); pServer .AdjustPolicyTaskManagerForDebug() .AddDebugMemoryDataCollector(out collector2) .AddPayloadSerializerDefaultJson() .AddChannelIncoming("internalIn", internalOnly: false , autosetPartition01: false , assign: (p, c) => cpipeIn = p) .AttachPriorityPartition((0, 1.0M), (1, 0.9M)) .AttachListener(bridgeOut.GetListener()) .AttachMessagePriorityOverrideForResponse() .AttachCommand((CommandMethodRequestContext ctx) => { var payload = ctx.DtoGet <Blah>(); ctx.ResponseSet(200, payload.Message); return(Task.FromResult(0)); }, ("franky", "johnny5")) .AttachCommand((CommandMethodRequestContext ctx) => { var payload = ctx.DtoGet <Blah>(); ctx.ResponseSet(201, payload.Message); return(Task.FromResult(0)); }, ("franky", "johnny6")) .Revert() .AddChannelOutgoing("return") .AttachSender(bridgeReturn.GetSender()) .Revert(); ; pClient .AdjustPolicyTaskManagerForDebug() .AddDebugMemoryDataCollector(out collector1) .AddChannelIncoming("spooky", internalOnly: true) .AttachCommand((CommandMethodRequestContext ctx) => { var payload = ctx.DtoGet <Blah>(); ctx.ResponseSet(200, payload.Message); return(Task.FromResult(0)); }, ("franky", "johnny5")) .Revert() .AddChannelIncoming("return") .AttachListener(bridgeReturn.GetListener()) .AttachMessagePriorityOverrideForResponse() .AttachCommandInitiator(out init) .Revert() .AddChannelOutgoing("internalIn", internalOnly: false , autosetPartition01: false , assign: (p, c) => cpipeOut = p) .AttachPriorityPartition(0, 1) .AttachSender(bridgeOut.GetSender()) .Revert() ; pClient2 .AdjustPolicyTaskManagerForDebug() .AddDebugMemoryDataCollector(out collector1a) .AddChannelIncoming("spooky", internalOnly: true) .AttachCommand((CommandMethodRequestContext ctx) => { var payload = ctx.DtoGet <Blah>(); ctx.ResponseSet(200, payload.Message); return(Task.FromResult(0)); }, ("franky", "johnny5")) .Revert() .AddChannelIncoming("return") .AttachListener(bridgeReturn.GetListener()) .AttachMessagePriorityOverrideForResponse() .AttachCommandInitiator(out init2) .Revert() .AddChannelOutgoing("internalIn", internalOnly: false , autosetPartition01: false) .AttachPriorityPartition(0, 1) .AttachSender(bridgeOut.GetSender()) .Revert() ; pClient.Start(); pClient2.Start(); pServer.Start(); init.OnRequestUnresolved += Init_OnRequestUnresolved; init2.OnRequestUnresolved += Init_OnRequestUnresolved; var list = new List <Task <ResponseWrapper <string> > >(); list.Add(init.Process <IPipelineTest2, Blah, string>(new Blah() { Message = "hello1" })); list.Add(init.Process <Blah, string>("internalIn", "franky", "johnny5", new Blah() { Message = "hello2" })); list.Add(init.Process <Blah, string>(("internalIn", "franky", "johnny5"), new Blah() { Message = "hello3" })); list.Add(init.Process <Blah, string>(("internalIn", "franky", "johnny6"), new Blah() { Message = "hello3" })); list.Add(init.Process <Blah, string>(("spooky", "franky", "johnny5"), new Blah() { Message = "hellospooky" })); var result = Task.WhenAll(list).Result; result.ForEach((r) => Assert.IsTrue(r.ResponseCode == 200 || r.ResponseCode == 201)); pClient.Stop(); pClient2.Stop(); pServer.Stop(); } catch (Exception ex) { Assert.Fail(ex.Message); } }
private void Hello2(IPipelineChannelIncoming <WebApiMicroservicePipeline> pipeEx) { }