public async Task <IGrainReminder> StartReminder(string reminderName, TimeSpan?p = null, bool validate = false) { TimeSpan usePeriod = p ?? period; logger.Info("Starting reminder {0} for {1}", reminderName, RuntimeIdentity.ToString()); IGrainReminder r = null; if (validate) { r = await RegisterOrUpdateReminder(reminderName, /*TimeSpan.FromSeconds(3)*/ usePeriod - TimeSpan.FromSeconds(2), usePeriod); } else { r = await base.RegisterOrUpdateReminder(reminderName, /*TimeSpan.FromSeconds(3)*/ usePeriod - TimeSpan.FromSeconds(2), usePeriod); } if (allReminders.ContainsKey(reminderName)) { allReminders[reminderName] = r; sequence[reminderName] = 0; } else { allReminders.Add(reminderName, r); sequence.Add(reminderName, 0); } File.Delete(GetFileName(reminderName)); // if successfully started, then remove any old data logger.Info("Started reminder {0}.", r); return(r); }
public override Task OnActivateAsync() { myId = new Random().Next().ToString();//this.Data.ActivationId.ToString();// new Random().Next(); allReminders = new Dictionary <string, IGrainReminder>(); sequence = new Dictionary <string, long>(); logger = GetLogger(string.Format("ReminderTestGrain {0}_{1}", RuntimeIdentity.ToString(), RuntimeIdentity.ToString())); period = GetDefaultPeriod(logger); logger.Info("OnActivateAsync."); filePrefix = "g" + this.IdentityString + "_"; return(GetMissingReminders()); }
public string GetRuntimeIdentity() { if (!string.IsNullOrEmpty(RuntimeIdentity)) { string[] arr = RuntimeIdentity.Split(new char[1] { ':' }); if (arr.Length >= 3) { return(arr[0].Replace("S", "") + ":" + arr[1]); } } return(RuntimeIdentity); }
public static void LoadAwsIdentity(this IConfiguration @this) { RuntimeIdentity.Load(@this).WaitAndThrow(); var secrets = ObtainRuntimeIdentitySecret(@this); var jsonProvider = new JsonConfigurationProvider(secrets); jsonProvider.Load(); foreach (var item in jsonProvider.GetData()) { @this[item.Key] = item.Value; } }
public override Task OnActivateAsync() { logger = GetLogger(String.Format("WrongReminderGrain_{0}", RuntimeIdentity.ToString())); logger.Info("OnActivateAsync."); return(TaskDone.Done); }
public static void LoadAwsIdentity(this IConfiguration @this) { RuntimeIdentity.Load(@this).WaitAndThrow(); new Secrets(@this).Load(); }