Example #1
0
 public static string ContinueWith <T>(
     [NotNull] string parentId,
     [NotNull, InstantHandle] Expression <Action <T> > methodCall,
     JobContinuationOptions options)
 {
     return(ContinueJobWith(parentId, methodCall, options));
 }
Example #2
0
        public string Schedule([NotNull, InstantHandle] Expression <Action> action, DateTime enqueueAt,
                               JobContinuationOptions atomProgress = JobContinuationOptions.OnlyOnSucceededState)
        {
            var state = new ScheduledState(enqueueAt);

            return(CreateSubatomInternal(action, state, atomProgress));
        }
Example #3
0
        public string Enqueue([NotNull, InstantHandle] Expression <Action> action,
                              JobContinuationOptions atomProgress = JobContinuationOptions.OnlyOnSucceededState)
        {
            var state = new EnqueuedState();

            return(CreateSubatomInternal(action, state, atomProgress));
        }
Example #4
0
 public static string ContinueWith <T>(
     [NotNull] string parentId,
     [NotNull, InstantHandle] Expression <Func <T, Task> > methodCall,
     JobContinuationOptions options = JobContinuationOptions.OnlyOnSucceededState)
 {
     return(ContinueJobWith(parentId, methodCall, options));
 }
Example #5
0
        public string Schedule([NotNull, InstantHandle] Expression <Func <Task> > action, TimeSpan enqueueIn,
                               JobContinuationOptions atomProgress = JobContinuationOptions.OnlyOnSucceededState)
        {
            var state = new ScheduledState(enqueueIn);

            return(CreateSubatomInternal(action, state, atomProgress));
        }
Example #6
0
 public string Enqueue(
     [InstantHandle] Expression <Func <Task> > action,
     IState state,
     JobContinuationOptions atomProgress = JobContinuationOptions.OnlyOnSucceededState)
 {
     return(CreateSubatomInternal(action, state, atomProgress));
 }
Example #7
0
        public string OnTriggerSet(string triggerName, [NotNull, InstantHandle] Expression <Func <Task> > action,
                                   JobContinuationOptions atomProgress = JobContinuationOptions.OnlyOnSucceededState)
        {
            var state = new TriggerWaitingState(triggerName);

            return(CreateSubatomInternal(action, state, atomProgress));
        }
Example #8
0
 /// <summary>
 /// Creates a new background job that will wait for another background job to be triggered
 /// in the <see cref="EnqueuedState"/>.
 /// </summary>
 /// <param name="client">A job client instance.</param>
 /// <param name="parentId">Identifier of a background job to wait completion for.</param>
 /// <param name="methodCall">Method call expression that will be marshalled to a server.</param>
 /// <param name="options">Continuation options.</param>
 /// <returns>Unique identifier of a created job.</returns>
 public static string ContinueWith <T>(
     [NotNull] this IBackgroundJobClient client,
     [NotNull] string parentId,
     [NotNull, InstantHandle] Expression <Action <T> > methodCall,
     JobContinuationOptions options)
 {
     return(ContinueWith(client, parentId, methodCall, new EnqueuedState(), options));
 }
Example #9
0
 public string ContinueJobWith <T>(
     string parentId,
     [InstantHandle] Expression <Action <T> > action,
     JobContinuationOptions jobContinuationOptions = JobContinuationOptions.OnlyOnSucceededState,
     JobContinuationOptions atomProgress           = JobContinuationOptions.OnlyOnSucceededState)
 {
     return(ContinueJobWith(parentId, action, new EnqueuedState(), jobContinuationOptions, atomProgress));
 }
Example #10
0
        public string ContinueJobWith(string parentId, [NotNull, InstantHandle] Expression <Func <Task> > action,
                                      JobContinuationOptions continuationOptions = JobContinuationOptions.OnlyOnSucceededState,
                                      JobContinuationOptions atomProgress        = JobContinuationOptions.OnlyOnSucceededState)
        {
            var state = new AwaitingState(parentId, new EnqueuedState(), continuationOptions);

            return(CreateSubatomInternal(action, state, atomProgress));
        }
Example #11
0
        public string Enqueue <T>(
            [InstantHandle] Expression <Action <T> > action,
            JobContinuationOptions atomProgress = JobContinuationOptions.OnlyOnSucceededState)
        {
            var job       = Job.FromExpression(action);
            var nextState = new EnqueuedState();

            return(CreateSubatomInternal(job, nextState, atomProgress));
        }
Example #12
0
        /// <summary>
        /// Creates a new background job that will wait for another background job to be enqueued.
        /// </summary>
        /// <param name="parentId">Identifier of a background job to wait completion for.</param>
        /// <param name="methodCall">Method call expression that will be marshalled to a server.</param>
        /// <param name="options">Continuation options. By default,
        /// <see cref="JobContinuationOptions.OnlyOnSucceededState"/> is used.</param>
        /// <returns>Unique identifier of a created job.</returns>
        public static string ContinueJobWith(
            [NotNull] string parentId,
            [NotNull, InstantHandle] Expression <Func <Task> > methodCall,
            JobContinuationOptions options = JobContinuationOptions.OnlyOnSucceededState)
        {
            var client = ClientFactory();

            return(client.ContinueJobWith(parentId, methodCall, options: options));
        }
Example #13
0
        /// <summary>
        /// Execute the command only once but when its parent job has been finished.
        /// </summary>
        /// <param name="request">Request to be send.</param>
        /// <param name="parentJobId">Parent job id.</param>
        /// <param name="continuationOption">Continuation option.</param>
        /// <returns>Unique identifier of a created job.</returns>
        public string SendCommand(IRequest request, string parentJobId, JobContinuationOptions continuationOption)
        {
            CheckIfOperationIsSupported();

            var mediatorSerializedObject = SerializeObject(request);

            return(BackgroundJob.ContinueJobWith(parentJobId,
                                                 () => _messageExecutor.ExecuteCommand(mediatorSerializedObject), continuationOption));
        }
Example #14
0
        /// <summary>
        /// Creates a new background job that will wait for another background job to be enqueued.
        /// </summary>
        /// <param name="parentId">Identifier of a background job to wait completion for.</param>
        /// <param name="methodCall">Method call expression that will be marshalled to a server.</param>
        /// <param name="options">Continuation options.</param>
        /// <returns>Unique identifier of a created job.</returns>
        public static string ContinueJobWith <T>(
            [NotNull] string parentId,
            [NotNull, InstantHandle] Expression <Action <T> > methodCall,
            JobContinuationOptions options)
        {
            var client = ClientFactory();

            return(client.ContinueJobWith(parentId, methodCall, options));
        }
Example #15
0
 public static string ContinueWith(
     [NotNull] this IBackgroundJobClient client,
     [NotNull] string parentId,
     [InstantHandle] Expression <Action> methodCall,
     [NotNull] IState nextState,
     JobContinuationOptions options)
 {
     return(ContinueJobWith(client, parentId, methodCall, nextState, options));
 }
Example #16
0
 public static string ContinueWith <T>(
     [NotNull] this IBackgroundJobClient client,
     [NotNull] string parentId,
     [NotNull, InstantHandle] Expression <Func <T, Task> > methodCall,
     [CanBeNull] IState nextState   = null,
     JobContinuationOptions options = JobContinuationOptions.OnlyOnSucceededState)
 {
     return(ContinueJobWith(client, parentId, methodCall, nextState, options));
 }
Example #17
0
        public string Enqueue <T>(
            [InstantHandle] Expression <Func <T, Task> > action,
            IState state,
            JobContinuationOptions atomProgress = JobContinuationOptions.OnlyOnSucceededState)
        {
            var job = Job.FromExpression(action);

            return(CreateSubatomInternal(job, state, atomProgress));
        }
Example #18
0
        protected string CreateSubatomInternal(
            Job job,
            IState nextState,
            JobContinuationOptions continuationOptions)
        {
            var jobId = _client.Create(job, new SubAtomCreatedState(_atomId, nextState, continuationOptions));

            _createdSubAtoms.Add(jobId, nextState);
            return(jobId);
        }
Example #19
0
        /// <summary>
        /// Creates a new background job that will wait for another background job to be enqueued.
        /// </summary>
        /// <param name="parentId">Identifier of a background job to wait completion for.</param>
        /// <param name="methodCall">Method call expression that will be marshalled to a server.</param>
        /// <param name="options">Continuation options.</param>
        /// <param name="continuationQueueName">The name of the queue to place the continuation job in.
        /// This value overrides <see cref="QueueAttribute"/>.</param>
        /// <returns>Unique identifier of a created job.</returns>
        public static string ContinueWith <T>(
            [NotNull] string parentId,
            [NotNull, InstantHandle] Expression <Action <T> > methodCall,
            JobContinuationOptions options,
            [CanBeNull] string continuationQueueName = null)
        {
            var client = ClientFactory();

            return(client.ContinueWith(parentId, methodCall, options, continuationQueueName));
        }
Example #20
0
        /// <summary>
        /// Creates a new background job that will wait for another background job to be enqueued.
        /// </summary>
        /// <param name="parentId">Identifier of a background job to wait completion for.</param>
        /// <param name="methodCall">Method call expression that will be marshalled to a server.</param>
        /// <param name="options">Continuation options. By default,
        /// <see cref="JobContinuationOptions.OnlyOnSucceededState"/> is used.</param>
        /// <param name="continuationQueueName">The name of the queue to place the continuation job in.
        /// This value overrides <see cref="QueueAttribute"/>.</param>
        /// <returns>Unique identifier of a created job.</returns>
        public static string ContinueWith <T>(
            [NotNull] string parentId,
            [NotNull, InstantHandle] Expression <Func <T, Task> > methodCall,
            JobContinuationOptions options           = JobContinuationOptions.OnlyOnSucceededState,
            [CanBeNull] string continuationQueueName = null)
        {
            var client = ClientFactory();

            return(client.ContinueWith(parentId, methodCall, options: options, continuationQueueName: continuationQueueName));
        }
Example #21
0
        public string ContinueJobWith(
            string parentId,
            [InstantHandle] Expression <Func <Task> > action,
            IState state,
            JobContinuationOptions jobContinuationOptions = JobContinuationOptions.OnlyOnSucceededState,
            JobContinuationOptions atomProgress           = JobContinuationOptions.OnlyOnSucceededState)
        {
            var nextState = new AwaitingState(parentId, state, jobContinuationOptions);

            return(CreateSubatomInternal(action, nextState, atomProgress));
        }
Example #22
0
        public string ContinueJobWith <T>(
            string parentId,
            [InstantHandle] Expression <Action <T> > action,
            JobContinuationOptions jobContinuationOptions = JobContinuationOptions.OnlyOnSucceededState,
            JobContinuationOptions atomProgress           = JobContinuationOptions.OnlyOnSucceededState)
        {
            var job       = Job.FromExpression(action);
            var nextState = new AwaitingState(parentId, new EnqueuedState(), jobContinuationOptions);

            return(CreateSubatomInternal(job, nextState, atomProgress));
        }
Example #23
0
        public AwaitingState(
            [NotNull] string parentId,
            [NotNull] IState nextState,
            JobContinuationOptions options,
            TimeSpan expiration)
        {
            if (parentId == null) throw new ArgumentNullException("parentId");
            if (nextState == null) throw new ArgumentNullException("nextState");

            ParentId = parentId;
            NextState = nextState;

            Options = options;
            Expiration = expiration;
        }
Example #24
0
        /// <summary>
        /// Creates a new background job that will wait for another background job to be triggered
        /// in the <see cref="EnqueuedState"/>.
        /// </summary>
        /// <param name="client">A job client instance.</param>
        /// <param name="parentId">Identifier of a background job to wait completion for.</param>
        /// <param name="methodCall">Method call expression that will be marshalled to a server.</param>
        /// <param name="options">Continuation options.</param>
        /// <param name="continuationQueueName">The name of the queue to place the continuation job in.
        /// This value overrides <see cref="QueueAttribute"/>.</param>
        /// <returns>Unique identifier of a created job.</returns>
        public static string ContinueWith <T>(
            [NotNull] this IBackgroundJobClient client,
            [NotNull] string parentId,
            [NotNull, InstantHandle] Expression <Action <T> > methodCall,
            JobContinuationOptions options,
            [CanBeNull] string continuationQueueName = null)
        {
            if (continuationQueueName != null)
            {
                return(ContinueWith(client, parentId, methodCall, new EnqueuedState(continuationQueueName), options));
            }

            var job = Job.FromExpression(methodCall);

            return(ContinueWith(client, parentId, methodCall, new EnqueuedState(job.QueueName), options));
        }
Example #25
0
        /// <summary>
        /// Creates a new background job that will wait for another background job to be triggered.
        /// </summary>
        /// <param name="client">A job client instance.</param>
        /// <param name="parentId">Identifier of a background job to wait completion for.</param>
        /// <param name="methodCall">Method call expression that will be marshalled to a server.</param>
        /// <param name="nextState">Next state for a job, when continuation is triggered.
        /// If null, then <see cref="EnqueuedState"/> is used.</param>
        /// <param name="options">Continuation options. By default,
        /// <see cref="JobContinuationOptions.OnlyOnSucceededState"/> is used.</param>
        /// <returns>Unique identifier of a created job.</returns>
        public static string ContinueWith <T>(
            [NotNull] this IBackgroundJobClient client,
            [NotNull] string parentId,
            [NotNull, InstantHandle] Expression <Func <T, Task> > methodCall,
            [CanBeNull] IState nextState   = null,
            JobContinuationOptions options = JobContinuationOptions.OnlyOnSucceededState)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            var state = new AwaitingState(parentId, nextState ?? new EnqueuedState(), options);

            return(client.Create(Job.FromExpression(methodCall), state));
        }
Example #26
0
        /// <summary>
        /// Creates a new background job that will wait for another background job to be triggered.
        /// </summary>
        /// <param name="client">A job client instance.</param>
        /// <param name="parentId">Identifier of a background job to wait completion for.</param>
        /// <param name="methodCall">Method call expression that will be marshalled to a server.</param>
        /// <param name="nextState">Next state for a job, when continuation is triggered.</param>
        /// <param name="options">Continuation options.</param>
        /// <returns>Unique identifier of a created job.</returns>
        public static string ContinueWith <T>(
            [NotNull] this IBackgroundJobClient client,
            [NotNull] string parentId,
            [NotNull, InstantHandle] Expression <Action <T> > methodCall,
            [NotNull] IState nextState,
            JobContinuationOptions options)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            var state = new AwaitingState(parentId, nextState, options);

            return(client.Create(Job.FromExpression(methodCall), state));
        }
Example #27
0
        public AwaitingState(
            [NotNull] string parentId,
            [NotNull] IState nextState,
            JobContinuationOptions options,
            TimeSpan expiration)
        {
            if (parentId == null)
            {
                throw new ArgumentNullException(nameof(parentId));
            }
            if (nextState == null)
            {
                throw new ArgumentNullException(nameof(nextState));
            }

            ParentId  = parentId;
            NextState = nextState;

            Options    = options;
            Expiration = expiration;
        }
Example #28
0
        public static void SetSubAtomContinuation(this IStorageConnection connection, string subatomId, JobContinuationOptions continuationOptions)
        {
            var serializedOptions = continuationOptions.ToString("G");

            connection.SetJobParameter(subatomId, Atom.ParameterSubatomContinuation, serializedOptions);
        }
Example #29
0
 public AwaitingState(string parentId, IState nextState, JobContinuationOptions options)
     : this(parentId, nextState, options, DefaultExpiration)
 {
 }
Example #30
0
 public BatchTask ContinueWith <T>(Expression <Action <T> > methodCall, JobContinuationOptions options = JobContinuationOptions.OnAnyFinishedState)
 {
     _parentJobId = BackgroundJob.ContinueJobWith <T>(_parentJobId, methodCall, options);
     return(this);
 }
Example #31
0
        public string SendNow(IRequest request, string parentJobId, JobContinuationOptions continuationOption, string description = null)
        {
            var mediatorSerializedObject = SerializeObject(request, description);

            return(BackgroundJob.ContinueJobWith(parentJobId, () => commandsExecutor.ExecuteCommand(mediatorSerializedObject), continuationOption));
        }
Example #32
0
 public string Enqueue(MediatorSerializedObject mediatorSerializedObject, string parentJobId, JobContinuationOptions continuationOption, string description = null)
 {
     return(BackgroundJob.ContinueJobWith(parentJobId, () => _commandsExecutor.ExecuteCommand(mediatorSerializedObject), continuationOption));
 }