public async Task TestTask_T_CancellationToken(IActorFactory fact) { Output(fact.Type.ToString()); var one = new PingPongerAsyncCancellable("Noa"); var actor1 = fact.Build <IPingPongerAsyncCancellable>(one); var two = new PingPongerAsyncCancellable("Wilander"); var actor2 = fact.Build <IPingPongerAsyncCancellable>(two); one.PongerAsync = actor2; two.PongerAsync = actor1; var watch = Stopwatch.StartNew(); await actor1.Ping(CancellationToken.None); Thread.Sleep(10000); await fact.DisposeAsync(); watch.Stop(); Output($"Total Ping:{one.Count}, Total Pong:{two.Count} Total Time: {watch.ElapsedMilliseconds} ms"); Output($"Operation/ms:{(one.Count + two.Count) / watch.ElapsedMilliseconds}"); }
public ActorManager(ILogger <ActorManager> logger, ActorSystem actorSystem, IActorFactory actorFactory) { this.logger = logger; this.actorSystem = actorSystem; this.actorFactory = actorFactory; logger.LogInformation("ActorManager Instance created " + System.Threading.Thread.GetCurrentProcessorId()); }
public DistributedActorTableContainer(string name, IActorRef clusterActorDiscovery, Type actorFactoryType, object[] actorFactoryInitalizeArgs, object downMessage = null) { _name = name; _clusterActorDiscovery = clusterActorDiscovery; _downMessage = downMessage; _log = Context.GetLogger(); if (actorFactoryType != null) { try { _actorFactory = (IActorFactory)Activator.CreateInstance(actorFactoryType); _actorFactory.Initialize(actorFactoryInitalizeArgs); } catch (Exception e) { _log.Error(e, $"Exception in initializing ${actorFactoryType.FullName}"); _actorFactory = null; } } Receive <ClusterActorDiscoveryMessage.ActorUp>(m => Handle(m)); Receive <ClusterActorDiscoveryMessage.ActorDown>(m => Handle(m)); Receive <DistributedActorTableMessage <TKey> .Add>(m => Handle(m)); Receive <DistributedActorTableMessage <TKey> .Remove>(m => Handle(m)); Receive <DistributedActorTableMessage <TKey> .Internal.Create>(m => Handle(m)); Receive <DistributedActorTableMessage <TKey> .Internal.AddReply>(m => Handle(m)); Receive <DistributedActorTableMessage <TKey> .Internal.GracefulStop>(m => Handle(m)); Receive <Terminated>(m => Handle(m)); }
public SynchronizationContextFactoryTest() { _UiMessageLoop = new WpfThreadingHelper(); _UiMessageLoop.Start().Wait(); _Factory = _UiMessageLoop.Dispatcher.Invoke(() => _FactoryBuilder.GetInContextFactory()); }
internal ActorConfigurator(IActorFactory actorFactory, IComponentFactory componentFactory) { _componentFactory = componentFactory; _actorFactory = actorFactory; _components = new List <IComponent>(); _id = null; }
public async Task TestNoTask(IActorFactory fact) { Output(fact.Type.ToString()); var one = new PingPongerSimple("Bjorg"); var actor1 = fact.Build <IPingPonger>(one); var two = new PingPongerSimple("Lendl"); var actor2 = fact.Build <IPingPonger>(two); one.Ponger = actor2; two.Ponger = actor1; var watch = Stopwatch.StartNew(); actor1.Ping(); Thread.Sleep(10000); await fact.DisposeAsync(); watch.Stop(); Output($"Total Ping:{one.Count}, Total Pong:{two.Count} Total Time: {watch.ElapsedMilliseconds} ms"); Output($"Operation/ms:{(one.Count + two.Count) / watch.ElapsedMilliseconds}"); }
public ProductActor(IActorFactory actorFactory, ILoggerFactory loggerFactory, ICommandDispatcher commandDispatcher) { this.actorFactory = actorFactory; this.logger = loggerFactory.CreateLogger <ProductActor>(); this.commandDispatcher = commandDispatcher; }
public ConsoleApplication( ActorSystem system, IActorFactory actorFactory) { _system = system; _actorFactory = actorFactory; _chatClientActor = _actorFactory.CreateActor <ChatClientActor>("ChatClient"); }
public ConsoleApplication( ActorSystem system, IActorFactory actorFactory) { _system = system; _actorFactory = actorFactory; _consoleReaderActor = _actorFactory.CreateActor <ConsoleReaderActor>(); }
protected ConfigurationService(IMapper mapper, ILogger <ConfigurationService> logger, IActorFactory actorFactory, IServiceProvider serviceProvider, IRoslynCompilerService roslynCompilerService) { _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); _logger = logger; _actorFactory = actorFactory; _serviceProvider = serviceProvider; _roslynCompilerService = roslynCompilerService; }
public void Creating_SynchronizationContextFactory_WithoutContext_ThrowException() { SynchronizationContext.SetSynchronizationContext(null); IActorFactory res = null; Action Do = () => res = _FactoryBuilder.GetInContextFactory(); Do.Should().Throw <ArgumentNullException>(); }
public UsersService(StatefulServiceContext context, IUsersRepository usersRepository, IActorFactory actorFactory = null, IServiceFactory serviceFactory = null) : base(context, actorFactory, serviceFactory) { if (usersRepository == null) { throw new ArgumentNullException(nameof(usersRepository)); } this.usersRepository = usersRepository; }
public Dequeuer( ISQSClient sqsClient, ILogger logger, IActorFactory factory, IMessageMapper mapper) { _sqsClient = sqsClient ?? throw new ArgumentNullException(nameof(sqsClient)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _factory = factory ?? throw new ArgumentNullException(nameof(factory)); _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); }
public VehiclesService(StatefulServiceContext context, IReliableStateManagerReplica stateManager, IVehiclesRepository vehiclesRepository, IActorFactory actorFactory = null, IServiceFactory serviceFactory = null) : base(context, stateManager, actorFactory, serviceFactory) { if (vehiclesRepository == null) { throw new ArgumentNullException(nameof(vehiclesRepository)); } this.vehiclesRepository = vehiclesRepository; }
public MailService(StatefulServiceContext context, IReliableStateManagerReplica stateManager, MailAdapterBase mailAdapter, IActorFactory actorFactory = null, IServiceFactory serviceFactory = null) : base(context, stateManager, actorFactory, serviceFactory) { if (mailAdapter == null) { throw new ArgumentNullException(nameof(mailAdapter)); } this.mailAdapter = mailAdapter; this.mailAdapter.SetParent(this); }
public DefaultAgent( IActorCache <TActor> cache, IActorStore <TActor> store, IActorFactory <TActor> factory, IMemoizer memoizer) { Memoizer = memoizer; Cache = cache; Store = store; Factory = factory; Actors = new ExclusiveConcurrentDictionary <string, TActor>(); }
public ActorFactoryShould() { _actorBuilder = new Mock <IActorBuilder <TestActor> >(); _actorBuilder .Setup(builder => builder.Build(It.IsAny <int>(), It.IsAny <IComponent[]>())) .Returns <int, IComponent[]>((id, components) => new TestActor(id, components)); _actorFactory = new ActorFactory( Mock.Of <IActorContext>(), Mock.Of <IComponentFactory>(), new IActorBuilder[] { _actorBuilder.Object }); }
public VehicleActor(ActorService actorService, ActorId actorId, IActorFactory actorFactory, IServiceFactory serviceFactory, IVehiclesServiceProxy vehiclesServiceProxy) : base(actorService, actorId, actorFactory, serviceFactory) { if (vehiclesServiceProxy == null) { this.vehiclesServiceProxy = VehiclesServiceProxy.Instance; } else { this.vehiclesServiceProxy = vehiclesServiceProxy; } }
public ConsoleWriterActor(ILogger <ConsoleWriterActor> logger, IActorFactory actorFactory) { _logger = logger; ReceiveAsync <Messages.ConsoleWriterMessages.PrintInstructions>(async _ => { DoPrintInstructions(); }); ReceiveAsync <Messages.ConsoleWriterMessages.PrintMessage>(async cmd => { var color = ConsoleColor.Green; Console.ForegroundColor = color; Console.WriteLine(cmd.Message); Console.ResetColor(); }); }
public EntityState( IActorContext actors, IActorFactory actorFactory, IAssetContext assets, IConvertersCollection converters, SourceDescriptions descriptions) { Actors = actors; Assets = assets; _actorFactory = actorFactory; _converters = converters; _descriptions = descriptions; }
public Router(Guid id, IActorFactory <ActorInit> actorFactory, ActorInit config, IContext context) { this.Id = id; this.actorFactory = actorFactory; this.Config = config; this.Context = context; this.actors = new Dictionary <Guid, IActor>(); this.emptyActors = new Queue <IActor>(); this.workloads = new Queue <Workload>(); this.AddActor(); this.AddActor(); this.AddActor(); this.AddActor(); }
public UsersController(IUsersServiceProxy usersServiceProxy, IActorFactory actorFactory) { if (usersServiceProxy == null) { throw new ArgumentNullException(nameof(usersServiceProxy)); } if (actorFactory == null) { throw new ArgumentNullException(nameof(actorFactory)); } this.usersServiceProxy = usersServiceProxy; this.actorFactory = actorFactory; }
public PaymentController(IActorFactory actorFactory, IPaymentAdapter paymentAdapter) { if (actorFactory == null) { throw new ArgumentNullException(nameof(actorFactory)); } if (paymentAdapter == null) { throw new ArgumentNullException(nameof(paymentAdapter)); } this.actorFactory = actorFactory; this.paymentAdapter = paymentAdapter; }
public TestActor(IActorFactory actorFactory) { _actorFactory = actorFactory; Receive <GetUserDetail>(c => { var junk = c.UserId; //_log.Debug("received GetUserDetail vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"); }); ReceiveAny(c => { var junk = "sdsd"; }); }
protected ActorBase(ActorService actorService, ActorId actorId, IActorFactory actorFactory, IServiceFactory serviceFactory) : base(actorService, actorId) { if (actorFactory == null) { throw new ArgumentNullException(nameof(actorFactory)); } if (serviceFactory == null) { throw new ArgumentNullException(nameof(serviceFactory)); } this.actorFactory = actorFactory; this.serviceFactory = serviceFactory; }
public ActorManager(IActorFactory actorFactory, IProvider persistenceProvider, IOptions <ActorSettings> actorSettings, ITracer tracer, ILoggerFactory loggerFactory) { _actorFactory = actorFactory; var settings = actorSettings.Value; var logger = loggerFactory.CreateLogger <ActorManager>(); // Configure OpenTracing Context = new RootContext(new MessageHeader(), OpenTracingExtensions.OpenTracingSenderMiddleware()) .WithOpenTracing(); _actorFactory.RegisterActor(new RequestActor(this, persistenceProvider, TimeSpan.FromMilliseconds(settings.ChildActorTimeoutInMilliseconds), loggerFactory, tracer), ActorNames.RequestActor); EventStream.Instance.Subscribe <DeadLetterEvent>(dl => { logger.LogWarning($"DeadLetter from {dl.Sender} to {dl.Pid} : {dl.Message?.GetType().Name} = '{dl.Message?.ToString()}'"); }); }
internal static InvoiceActor CreateActor(ActorId id, IActorFactory actorFactory = null, IServiceFactory serviceFactory = null) { if (actorFactory == null) { actorFactory = new Mock <IActorFactory>().Object; } if (serviceFactory == null) { serviceFactory = new Mock <IServiceFactory>().Object; } Func <ActorService, ActorId, ActorBase> factory = (service, actorId) => new InvoiceActor(service, id, actorFactory, serviceFactory); var svc = MockActorServiceFactory.CreateActorServiceForActor <InvoiceActor>(factory); var actor = svc.Activate(id); return(actor); }
public UserActor(ActorService actorService, ActorId actorId, IActorFactory actorFactory, IServiceFactory serviceFactory, IUsersServiceProxy usersServiceProxy, IInvoicesServiceProxy invoicesServiceProxy) : base(actorService, actorId, actorFactory, serviceFactory) { if (usersServiceProxy == null) { this.usersServiceProxy = UsersServiceProxy.Instance; } else { this.usersServiceProxy = usersServiceProxy; } if (invoicesServiceProxy == null) { this.invoicesServiceProxy = InvoicesServiceProxy.Instance; } else { this.invoicesServiceProxy = invoicesServiceProxy; } }
protected StatefulServiceBase(StatefulServiceContext context, IActorFactory actorFactory = null, IServiceFactory serviceFactory = null) : base(context) { if (actorFactory == null) { this.actorFactory = new ReliableFactory(); } else { this.actorFactory = actorFactory; } if (serviceFactory == null) { this.serviceFactory = new ReliableFactory(); } else { this.serviceFactory = serviceFactory; } }
public TaskPoolActorFactoryTest() { _TaskPoolActorFactory = new FactoryBuilder().GetTaskBasedFactory(); }
void IGameSetters.SetActorFactory(IActorFactory actorFactory) { throw new NotImplementedException(); }
private static object[] BuildTestData(IActorFactory factory, IDoStuff stuffer) { return new object[] { factory.Build(stuffer), true }; }