Exemplo n.º 1
0
 public ActorReminder(
     ActorId actorId,
     string reminderName,
     ReminderInfo reminderInfo)
 {
     this.OwnerActorId = actorId;
     this.Name         = reminderName;
     this.ReminderInfo = reminderInfo;
 }
Exemplo n.º 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 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);
        }
Exemplo n.º 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);
            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());
        }