Exemple #1
0
 protected internal override void Define()
 {
     On((HasBeenReminded x) => reminded);
     On((SetReminder x) => reminders.Register("test", TimeSpan.Zero, x.Period));
     On((GetInstanceHashcode x) => RuntimeHelpers.GetHashCode(this));
     On((Deactivate x) => activation.DeactivateOnIdle());
 }
Exemple #2
0
        async Task Store(ICollection <object> events)
        {
            if (events.Count == 0)
            {
                return;
            }

            var serialized = events.Select(ToEventData).ToArray();

            try
            {
                var result = await Stream.WriteAsync(stream, serialized);

                stream = result.Stream;
            }
            catch (ConcurrencyConflictException)
            {
                Console.WriteLine("Concurrency conflict on stream '{0}' detected", StreamName());
                Console.WriteLine("Probably, second activation of actor '{0}' has been created", Self);
                Console.WriteLine("Deactivating duplicate activation '{0}' ... ", Self);

                activation.DeactivateOnIdle();
                throw new InvalidOperationException("Duplicate activation of actor '" + Self + "' detected");
            }
        }
Exemple #3
0
        async Task Store(ICollection <Event> events)
        {
            if (events.Count == 0)
            {
                return;
            }

            var stream     = StreamName();
            var serialized = events.Select(ToEventData).ToArray();

            try
            {
                await ES.Connection.AppendToStreamAsync(stream, version, serialized);
            }
            catch (WrongExpectedVersionException)
            {
                Console.WriteLine("Concurrency conflict on stream '{0}' detected", StreamName());
                Console.WriteLine("Probably, second activation of actor '{0}' has been created", Self);
                Console.WriteLine("Deactivating duplicate activation '{0}' ... ", Self);

                activation.DeactivateOnIdle();
                throw new InvalidOperationException("Duplicate activation of actor '" + Self + "' detected");
            }
        }
Exemple #4
0
 public Task Handle(SetReminder cmd)
 {
     reminders.Register("test", TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(60));
     activation.DeactivateOnIdle();
     return(TaskDone.Done);
 }