/// <summary>
 /// This is the default constructor for the memory persistence manager.
 /// This persistence manager is used to hold an in-memory JSON representation of the entity.
 /// It is primarily used for test purposes, but can be used in a production context.
 /// Please note that all data will be lost when the service is restarted.
 /// </summary>
 /// <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="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="policy">The policy.</param>
 /// <param name="prePopulate">The optional pre-population collection.</param>
 public PersistenceManagerHandlerMemory(Func <E, K> keyMaker
                                        , Func <string, K> keyDeserializer
                                        , 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
                                        , CommandPolicy policy           = null
                                        , IEnumerable <KeyValuePair <K, E> > prePopulate = null
                                        )
     : base(keyMaker
            , keyDeserializer
            , entityName
            , versionPolicy
            , defaultTimeout
            , persistenceRetryPolicy
            , resourceProfile
            , cacheManager
            , referenceMaker
            , referenceHashMaker
            , keySerializer
            , policy
            , prePopulate
            )
 {
 }
コード例 #2
0
 public static CommandSchedule ToCommandSchedule(this CommandPolicy policy, Func <Schedule
                                                                                  , CancellationToken, Task> execute, string name)
 {
     return(new CommandSchedule(execute
                                , policy.JobPollSchedule
                                , name
                                , policy.JobPollIsLongRunning));
 }
コード例 #3
0
 /// <summary>
 /// This is the constructor for registering a manual command.
 /// </summary>
 /// <param name="header">The ServiceMessageHeader route for the command.</param>
 /// <param name="command">The command to process.</param>
 /// <param name="referenceId">The optional reference id for tracking.</param>
 /// <param name="policy">The command policy.</param>
 public CommandMethodInline(ServiceMessageHeader header
                            , Func <CommandMethodRequestContext, Task> command
                            , string referenceId   = null
                            , CommandPolicy policy = null) : base(policy ?? new CommandPolicy() { OnProcessRequestException = ProcessRequestExceptionBehaviour.SignalSuccessAndSend500ErrorResponse })
 {
     mKey         = new MessageFilterWrapper(header, null);
     mCommand     = command;
     mReferenceId = referenceId;
 }
コード例 #4
0
 internal CommandHarnessDispatchWrapper(CommandPolicy policy
                                        , IServiceHandlers serviceHandlers
                                        , Action <TransmissionPayload, string> executeOrEnqueue
                                        , Func <ServiceStatus> getStatus
                                        , bool traceEnabled
                                        , string originatorServiceId = null)
     : base(serviceHandlers, executeOrEnqueue, getStatus, traceEnabled)
 {
     DefaultOriginatorServiceId = originatorServiceId;
     Policy = policy;
 }
コード例 #5
0
        /// <summary>
        /// This is the constructor for registering a manual schedule.
        /// </summary>
        /// <param name="command">The command to process.</param>
        /// <param name="config">The time configuration.</param>
        /// <param name="referenceId">The optional reference id for tracking.</param>
        /// <param name="isLongRunning">Specifies whether this is a long running process.</param>
        /// <param name="policy">The command policy.</param>
        public CommandScheduleInline(Func <CommandScheduleInlineContext, Task> command
                                     , ScheduleTimerConfig config = null
                                     , string referenceId         = null
                                     , bool isLongRunning         = false
                                     , CommandPolicy policy       = null) : base(policy)
        {
            mCommand = command ?? throw new ArgumentNullException("command", "The command function cannot be null");

            mTimerConfig   = config ?? new ScheduleTimerConfig(enforceSetting: false);
            mReferenceId   = referenceId;
            mIsLongRunning = isLongRunning;
        }
コード例 #6
0
ファイル: Command.cs プロジェクト: xigadee/Microservice
 public CommandBase(CommandPolicy policy = null) : base(policy)
 {
 }
コード例 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandHarness{C}"/> class.
 /// </summary>
 /// <param name="policy">The optional command policy.</param>
 /// <param name="commandCreator">This is the optional creator function to create the command.</param>
 public CommandHarness(CommandPolicy policy = null, Func <C> commandCreator = null) : base(policy, commandCreator)
 {
 }