Example #1
0
        public static EventStoreStatelessActorBuilder <TActor, TRegistry> Create(
            ClusterVNode clusterVNode,
            ConnectionSettings connectionSettings,
            IActorConfiguration actorConfiguration,
            ILoggerFactory?loggerFactory = null,
            Action <IEventStoreRepositoryConfiguration>?getEventStoreRepositoryConfiguration = null)

        {
            var connection = EmbeddedEventStoreConnection.Create(clusterVNode, connectionSettings);

            loggerFactory ??= new DummyLoggerFactory();

            var eventStoreRepositoryConfiguration = new EventStoreRepositoryConfiguration();

            getEventStoreRepositoryConfiguration?.Invoke(eventStoreRepositoryConfiguration);

            var connectionStatusMonitor = new EventStoreConnectionStatusMonitor(connection, loggerFactory);

            var eventStoreRepository = new EventStoreRepository(
                eventStoreRepositoryConfiguration,
                connection,
                connectionStatusMonitor,
                loggerFactory);

            var eventStoreStatelessActorBuilder = new EventStoreStatelessActorBuilder <TActor, TRegistry>(actorConfiguration, eventStoreRepository, connectionStatusMonitor, loggerFactory);

            return(eventStoreStatelessActorBuilder);
        }
Example #2
0
 public EventStoreStatefulActorBuilder(World world, IActorConfiguration actorConfiguration, IEventStoreActorConfigurationFactory eventStoreCacheFactory)
 {
     _streamsToRegisterTo    = new List <Func <IConnectionStatusMonitor <IEventStoreConnection>, ILoggerFactory, IEventStoreStream> >();
     _eventStoreCacheFactory = eventStoreCacheFactory;
     _actorConfiguration     = actorConfiguration;
     _busToRegisterTo        = new Dictionary <Type, Action <IServiceProvider, IActor> >();
     _world = world;
 }
Example #3
0
        /// <summary>
        /// Creates an actor with a key in the constructor
        /// </summary>
        /// <param name="dependencyResolver"></param>
        /// <param name="configuration"></param>
        /// <param name="key"></param>
        /// <param name="keyType"></param>
        /// <returns></returns>
        public static IActor CreateWithKeyDependency(IContainer dependencyResolver, IActorConfiguration configuration, object key, Type keyType)
        {
            // Strange behavior from JSON.NET - apparently if you serialize an integer but with object metadata, it gets de-serialized
            // as a 64-bit integer! So we need to change it manually back to the declared type
            var realKey = Convert.ChangeType(key, keyType);

            return(((IActor)dependencyResolver.Resolve(configuration.ActorType, new TypedParameter(keyType, realKey))).Configure(configuration));
        }
Example #4
0
 public Orchestrator(IActorConfiguration configuration,
                     IEventQueueOperator queueOperator,
                     IServiceLocator serviceLocator)
 {
     _queueOperator  = queueOperator;
     _serviceLocator = serviceLocator;
     _configuration  = configuration;
 }
Example #5
0
        public Orchestrator(IActorConfiguration configuration, 
            IEventQueueOperator queueOperator,
            IServiceLocator serviceLocator)
        {
            _queueOperator = queueOperator;
            _serviceLocator = serviceLocator;
            _configuration = configuration;
 
        }
        public static IActorManager ToActorManager(this IActorConfiguration self)
        {
            if (self == null)
            {
                return(null);
            }

            return(new ActorManager(self));
        }
        public static EventStoreStatelessActorBuilder <TActor, TRegistry> Create(string eventStoreConnectionString,
                                                                                 ConnectionSettingsBuilder connectionSettingsBuilder,
                                                                                 IActorConfiguration actorConfiguration,
                                                                                 ILoggerFactory loggerFactory = null,
                                                                                 Action <IEventStoreRepositoryConfiguration> getEventStoreRepositoryConfiguration = null)
        {
            var connection = EventStoreConnection.Create(eventStoreConnectionString, connectionSettingsBuilder);

            return(CreateInternal(actorConfiguration, connection, loggerFactory, getEventStoreRepositoryConfiguration));
        }
Example #8
0
        public static void ActorRegistered(this IActorConfiguration configuration, IWorkContext context, Type interfaceType, string message = null)
        {
            Verify.IsNotNull(nameof(configuration), configuration);
            Verify.IsNotNull(nameof(interfaceType), interfaceType);

            IEventDimensions dimensions = new EventDimensionsBuilder()
                                          .Add(nameof(interfaceType), interfaceType)
                                          .Add(nameof(message), message)
                                          .Build();

            configuration.WorkContext.EventLog.LogEvent(context, TelemetryLevel.Verbose, _actorEventName, nameof(ActorRegistered), dimensions);
        }
Example #9
0
        public static void ActorTimerCallback(this IActorConfiguration configuration, IWorkContext context, ActorKey actorKey, string message = null)
        {
            Verify.IsNotNull(nameof(configuration), configuration);
            Verify.IsNotNull(nameof(actorKey), actorKey);

            IEventDimensions dimensions = new EventDimensionsBuilder()
                                          .Add(nameof(actorKey), actorKey)
                                          .Add(nameof(message), message)
                                          .Build();

            configuration.WorkContext.EventLog.LogEvent(context, TelemetryLevel.Verbose, _actorEventName, nameof(ActorTimerCallback), dimensions);
        }
Example #10
0
        public ActorManager(IActorConfiguration configuration)
        {
            Verify.IsNotNull(nameof(configuration), configuration);

            Configuration    = configuration;
            _actorRepository = Configuration.ActorRepository ?? new ActorRepository(Configuration);

            foreach (ActorTypeRegistration registration in configuration?.Registration ?? Enumerable.Empty <ActorTypeRegistration>())
            {
                _typeManager.Register(_actorManagerWorkContext, registration);
            }
        }
        public ActorConfigurationBuilder(IActorConfiguration configuration)
        {
            Verify.IsNotNull(nameof(configuration), configuration);

            Capacity              = configuration.Capacity;
            ActorRepository       = configuration.ActorRepository;
            ActorCallTimeout      = configuration.ActorCallTimeout;
            ActorRetirementPeriod = configuration.ActorRetirementPeriod;
            InactivityScanPeriod  = configuration.InactivityScanPeriod;
            Registration          = configuration.Registration;
            WorkContext           = configuration.WorkContext;
        }
        public EventStoreStatefulActorBuilder(IActorConfiguration actorConfiguration,
                                              IEventStoreAggregateRepository eventStoreRepository,
                                              IConnectionStatusMonitor <IEventStoreConnection> connectionMonitor,
                                              ILoggerFactory loggerFactory
                                              )
        {
            ActorConfiguration   = actorConfiguration;
            EventStoreRepository = eventStoreRepository;
            LoggerFactory        = loggerFactory;
            ConnectionMonitor    = connectionMonitor;

            _busToRegisterTo = new Dictionary <Type, Action <Container, IActor> >();
        }
Example #13
0
        public static StatelessActorBuilder <TActor, TRegistry> Create(
            IActorConfiguration actorConfiguration,
            ILoggerFactory loggerFactory = null)
        {
            loggerFactory ??= new DummyLoggerFactory();

            var builder = new StatelessActorBuilder <TActor, TRegistry>
            {
                LoggerFactory      = loggerFactory,
                ActorConfiguration = actorConfiguration
            };

            return(builder);
        }
Example #14
0
        public ActorRepository(IActorConfiguration configuration)
        {
            Verify.IsNotNull(nameof(configuration), configuration);
            Verify.Assert(configuration.Capacity > 0, $"Capacity {configuration.Capacity} must be greater than 0");

            _workContext = new WorkContextBuilder(configuration.WorkContext)
                           .Set(_tag)
                           .Set(new CorrelationVector("Khooversoft-ActorRepository"))
                           .Build();

            _configuration = configuration;

            _actors = new LruCache <RegistrationKey, IActorRegistration>(_configuration.Capacity, new RegistrationKeyComparer());
            _actors.CacheItemRemoved += x => _actorRemovedQueue.Enqueue(x.Value);

            _timer = new Timer(GarbageCollection, null, _configuration.InactivityScanPeriod, _configuration.InactivityScanPeriod);
        }
        /// <summary>
        /// Updates the DegreeOfParallelism with entry from configuration in the form of Beehive.ActorParallelism.{ActorName}
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="configurationValueProvider"></param>
        /// <returns>an updated configuration</returns>
        public static IActorConfiguration UpdateParallelism(this IActorConfiguration configuration, IConfigurationValueProvider configurationValueProvider)
        {
            var descriptors = configuration.GetDescriptors()
                              .Select(descriptor =>
            {
                string value =
                    configurationValueProvider.GetValue("Beehive.ActorParallelism." + descriptor.ActorType.Name);
                int parallelism = descriptor.DegreeOfParallelism;

                if (int.TryParse(value, out parallelism))
                {
                    descriptor.DegreeOfParallelism = parallelism;
                }

                return(descriptor);
            });

            return(new NoNonsenseConfiguration(descriptors));
        }
        private static EventStoreStatelessActorBuilder <TActor, TRegistry> CreateInternal(
            IActorConfiguration actorConfiguration,
            IEventStoreConnection eventStoreConnection,
            ILoggerFactory loggerFactory = null,
            Action <IEventStoreRepositoryConfiguration> eventStoreRepositoryConfigurationBuilder = null)
        {
            loggerFactory ??= new DummyLoggerFactory();

            var eventStoreRepositoryConfiguration = new EventStoreRepositoryConfiguration();

            eventStoreRepositoryConfigurationBuilder?.Invoke(eventStoreRepositoryConfiguration);

            var connectionMonitor = new EventStoreConnectionStatusMonitor(eventStoreConnection, loggerFactory);

            var eventStoreRepository = new EventStoreAggregateRepository(
                eventStoreRepositoryConfiguration,
                eventStoreConnection,
                connectionMonitor,
                loggerFactory);

            var builder = new EventStoreStatelessActorBuilder <TActor, TRegistry>(actorConfiguration, eventStoreRepository, connectionMonitor, loggerFactory);

            return(builder);
        }
 public TestCatchupWithMailboxActor(IActorConfiguration actorConfiguration, IAggregateCache <SomeDataAggregate> eventStoreCache, ILoggerFactory loggerFactory = null) : base(actorConfiguration, eventStoreCache, loggerFactory)
 {
 }
Example #18
0
 public TestStatefulActorOneHealthChecksMvc(IActorConfiguration actorConfiguration, IAggregateCache <SomeDataAggregate> eventStoreCache, ILoggerFactory loggerFactory = null) : base(actorConfiguration, eventStoreCache, loggerFactory)
 {
 }
Example #19
0
 public TestStatelessActorOneHealthChecksMvc(IActorConfiguration actorConfiguration, ILoggerFactory loggerFactory = null) : base(actorConfiguration, loggerFactory)
 {
 }
Example #20
0
 public TestSingleQueueMqActor(IActorConfiguration actorConfiguration, ILoggerFactory loggerFactory = null) : base(actorConfiguration, loggerFactory)
 {
 }
 public TestBuilderActor(IActorConfiguration actorConfiguration, ILoggerFactory loggerFactory = null) : base(actorConfiguration, loggerFactory)
 {
 }
Example #22
0
 public EventCountStatelessActor(IActorConfiguration actorConfiguration, ILoggerFactory loggerFactory = null) : base(actorConfiguration, loggerFactory)
 {
 }
 public TradeSink(IActorConfiguration actorConfiguration, IAggregateCache <Trade> eventStoreCache, ILoggerFactory loggerFactory = null) : base(actorConfiguration, eventStoreCache, loggerFactory)
 {
 }
 public TestStatelessActor(IActorConfiguration actorConfiguration, ILoggerFactory loggerFactory = null) : base(actorConfiguration, loggerFactory)
 {
     ProcessedEvents = new List <IEvent>();
 }
Example #25
0
 public TestActorReceiver(IActorConfiguration actorConfiguration, ILoggerFactory loggerFactory = null) : base(actorConfiguration, loggerFactory)
 {
 }
Example #26
0
 /// <summary>
 /// Creates an actor according to the actor configuration's specified type and configures it
 /// </summary>
 /// <param name="dependencyResolver"></param>
 /// <param name="configuration"></param>
 /// <returns></returns>
 public static IActor Create(IContainer dependencyResolver, IActorConfiguration configuration)
 {
     return(((IActor)dependencyResolver.Resolve(configuration.ActorType)).Configure(configuration));
 }
Example #27
0
 public TestActorAutoBuildTwo(IActorConfiguration actorConfiguration, ILoggerFactory loggerFactory = null) : base(actorConfiguration, loggerFactory)
 {
 }
Example #28
0
 public void AddConfiguration <TActor>(IActorConfiguration actorConfiguration)
 {
     _actorConfigurations.Add(typeof(TActor), actorConfiguration);
 }
Example #29
0
 public EventCountStatefulActor(IActorConfiguration actorConfiguration, IAggregateCache <EventCountAggregate> eventStoreCache, ILoggerFactory loggerFactory = null) : base(actorConfiguration, eventStoreCache, loggerFactory)
 {
 }
 public TestMarketDataChangedActor(IActorConfiguration actorConfiguration, ILoggerFactory loggerFactory = null) : base(actorConfiguration, loggerFactory)
 {
 }
 public TestErrorHandlingStatefulActor(IActorConfiguration actorConfiguration, IAggregateCache <SomeDataAggregate> eventStoreCache, ILoggerFactory loggerFactory = null) : base(actorConfiguration, eventStoreCache, loggerFactory)
 {
 }