public override async Task RegisterReminderAsync(ActorReminder reminder)
        {
            if (reminder == null)
            {
                throw new ArgumentNullException(nameof(reminder));
            }

            var serialized = await SerializeReminderAsync(reminder);

            await this.interactor.RegisterReminderAsync(reminder.ActorType, reminder.ActorId.ToString(), reminder.Name, serialized);
        }
예제 #2
0
        /// <summary>
        /// Registers a reminder with the actor.
        /// </summary>
        /// <param name="reminderName">The name of the reminder to register. The name must be unique per actor.</param>
        /// <param name="state">User state passed to the reminder invocation.</param>
        /// <param name="dueTime">The amount of time to delay before invoking the reminder for the first time. Specify negative one (-1) milliseconds to disable invocation. Specify zero (0) to invoke the reminder immediately after registration.
        /// </param>
        /// <param name="period">
        /// The time interval between reminder invocations after the first invocation. Specify negative one (-1) milliseconds to disable periodic invocation.
        /// </param>
        /// <returns>
        /// A task that represents the asynchronous registration operation. The result of the task provides information about the registered reminder and is used to unregister the reminder using UnregisterReminderAsync />.
        /// </returns>
        /// <remarks>
        /// <para>
        /// The class deriving from <see cref="Dapr.Actors.Runtime.Actor" /> must implement <see cref="Dapr.Actors.Runtime.IRemindable" /> to consume reminder invocations. Multiple reminders can be registered at any time, uniquely identified by <paramref name="reminderName" />. Existing reminders can also be updated by calling this method again. Reminder invocations are synchronized both with other reminders and other actor method callbacks.
        /// </para>
        /// </remarks>
        protected async Task <IActorReminder> RegisterReminderAsync(
            string reminderName,
            byte[] state,
            TimeSpan dueTime,
            TimeSpan period)
        {
            var reminder = new ActorReminder(this.actorTypeName, this.Id, reminderName, state, dueTime, period);

            await this.Host.TimerManager.RegisterReminderAsync(reminder);

            return(reminder);
        }
예제 #3
0
        /// <summary>
        /// Registers a reminder with the actor.
        /// </summary>
        /// <param name="reminderName">The name of the reminder to register. The name must be unique per actor.</param>
        /// <param name="state">User state passed to the reminder invocation.</param>
        /// <param name="dueTime">The amount of time to delay before invoking the reminder for the first time. Specify negative one (-1) milliseconds to disable invocation. Specify zero (0) to invoke the reminder immediately after registration.
        /// </param>
        /// <param name="period">
        /// The time interval between reminder invocations after the first invocation. Specify negative one (-1) milliseconds to disable periodic invocation.
        /// </param>
        /// <returns>
        /// A task that represents the asynchronous registration operation. The result of the task provides information about the registered reminder and is used to unregister the reminder using UnregisterReminderAsync />.
        /// </returns>
        /// <remarks>
        /// <para>
        /// The class deriving from <see cref="Dapr.Actors.Runtime.Actor" /> must implement <see cref="Dapr.Actors.Runtime.IRemindable" /> to consume reminder invocations. Multiple reminders can be registered at any time, uniquely identified by <paramref name="reminderName" />. Existing reminders can also be updated by calling this method again. Reminder invocations are synchronized both with other reminders and other actor method callbacks.
        /// </para>
        /// </remarks>
        protected async Task <IActorReminder> RegisterReminderAsync(
            string reminderName,
            byte[] state,
            TimeSpan dueTime,
            TimeSpan period)
        {
            var reminderInfo = new ReminderInfo(state, dueTime, period);
            var reminder     = new ActorReminder(this.Id, reminderName, reminderInfo);
            await ActorRuntime.DaprInteractor.RegisterReminderAsync(this.actorImplementaionTypeName, this.Id.ToString(), reminderName, reminderInfo.SerializeToJson());

            return(reminder);
        }
예제 #4
0
        /// <summary>
        /// Registers a reminder with the actor.
        /// </summary>
        /// <param name="reminderName">The name of the reminder to register. The name must be unique per actor.</param>
        /// <param name="state">User state passed to the reminder invocation.</param>
        /// <param name="dueTime">The amount of time to delay before invoking the reminder for the first time. Specify negative one (-1) milliseconds to disable invocation. Specify zero (0) to invoke the reminder immediately after registration.
        /// </param>
        /// <param name="period">
        /// The time interval between reminder invocations after the first invocation. Specify negative one (-1) milliseconds to disable periodic invocation.
        /// </param>
        /// <returns>
        /// A task that represents the asynchronous registration operation. The result of the task provides information about the registered reminder and is used to unregister the reminder using UnregisterReminderAsync />.
        /// </returns>
        /// <remarks>
        /// <para>
        /// The class deriving from <see cref="Dapr.Actors.Runtime.Actor" /> must implement <see cref="Dapr.Actors.Runtime.IRemindable" /> to consume reminder invocations. Multiple reminders can be registered at any time, uniquely identified by <paramref name="reminderName" />. Existing reminders can also be updated by calling this method again. Reminder invocations are synchronized both with other reminders and other actor method callbacks.
        /// </para>
        /// </remarks>
        protected async Task <IActorReminder> RegisterReminderAsync(
            string reminderName,
            byte[] state,
            TimeSpan dueTime,
            TimeSpan period)
        {
            var reminderInfo           = new ReminderInfo(state, dueTime, period);
            var reminder               = new ActorReminder(this.Id, reminderName, reminderInfo);
            var serializedReminderInfo = await reminderInfo.SerializeAsync();

            await this.Host.DaprInteractor.RegisterReminderAsync(this.actorTypeName, this.Id.ToString(), reminderName, serializedReminderInfo);

            return(reminder);
        }
        private async ValueTask <string> SerializeReminderAsync(ActorReminder reminder)
        {
            var info = new ReminderInfo(reminder.State, reminder.DueTime, reminder.Period);

            return(await info.SerializeAsync());
        }
예제 #6
0
 public override Task RegisterReminderAsync(ActorReminder reminder)
 {
     throw new NotImplementedException(Message);
 }
예제 #7
0
 /// <summary>
 /// Registers the provided reminder with the runtime.
 /// </summary>
 /// <param name="reminder">The <see cref="ActorReminder" /> to register.</param>
 /// <returns>A task which will complete when the operation completes.</returns>
 public abstract Task RegisterReminderAsync(ActorReminder reminder);