public static ActorSelection ActorSelection(this IUntypedActorContext context, ActorMetaData targetActorMetaData) { var pathWithOutAdress = context.Self.Path.ToString().Replace(context.Self.Path.Address.ToString(), ""); var source = pathWithOutAdress.TrimStart('/').Split('/').ToList(); source.Reverse(); var target = new List <string>(); var currentActorMetaData = targetActorMetaData; while (currentActorMetaData != null) { if (currentActorMetaData.Name != null) { target.Add(currentActorMetaData.Name); } else { target.Add(null); } currentActorMetaData = currentActorMetaData.Parent; } target.Add("user"); string relativePath = CreateInterpretedRelativePath(source, target); return(context.ActorSelection(relativePath)); }
public static IActorRef GetOrCreate <TActor>(this IUntypedActorContext context, string actorName) where TActor : ActorBase, new() { var actor = context.Child(actorName); return(actor.IsNobody() ? context.ActorOf(Props.Create(() => new TActor()), actorName) : actor); }
private void LogToEverything(IUntypedActorContext context, string message) { //context.ActorSelection("akka.tcp://[email protected]:4063/user/StatusActor").Tell(new SignalRMessage(StaticMethods.GetServiceName(), "Privilege", message)); _mediator.Tell(new Publish(Topics.Status, new SignalRMessage($"{DateTime.Now}: {StaticMethods.GetSystemUniqueName()}", "Privilege", message)), context.Self); _logger.Info(message); }
public ViewModelActor(ISystemProcess process) : base(process) { ctx = Context; Command <LoadViewModel>(x => HandleProcessViews(x)); EventMessageBus.Current.GetEvent <ILoadViewModel>(Source).Subscribe(x => HandleProcessViews(x)); EventMessageBus.Current.Publish(new ServiceStarted <IViewModelService>(this, new StateEventInfo(process.Id, RevolutionData.Context.Actor.Events.ActorStarted), process, Source), Source); }
public virtual IActorRef Build(IUntypedActorContext context, string name) { return(context.ActorOf ( context.DI().Props <T>(), name )); }
public override IActorRef Build(IUntypedActorContext context, string name) { return(context.ActorOf ( context.DI().Props <Erc20BalanceIndexingActor>(), name )); }
public static IActorRef CreateActorHelper(IUntypedActorContext context, Props props, string actorName) { IActorRef actorRef = context.ActorOf(props, actorName); ColoredConsole.WriteCreationEvent($"CREATED '{actorName}' actor."); return(actorRef); }
public void Handle( IUntypedActorContext context, IActorRef manager, string aggregateId) { context.GetLogger().Info(aggregateId); manager.Tell(new ReportAggregateId(aggregateId)); }
public ActorAccess(IUntypedActorContext context, Tuple <InjectedActors, InjectedActors, InjectedActors, InjectedActors> actorChildren, MockActorBase actorItSelf, IStash stash, Action <Receive> become) { Context = context; ActorItSelf = actorItSelf; ActorChildren = actorChildren; Stash = stash; Become = become; }
//TODO: Track Actor Shutdown instead of just broadcast public ProcessSupervisor(bool autoRun, ISystemStarted firstMsg, List <IProcessInfo> processInfos, List <IComplexEventAction> processComplexEvents) : base(firstMsg.Process) { ctx = Context; ProcessInfos = processInfos; ProcessComplexEvents = processComplexEvents; EventMessageBus.Current.GetEvent <IStartSystemProcess>(Source).Where(x => autoRun && x.ProcessToBeStartedId == ProcessActions.NullProcess).Subscribe(x => StartParentProcess(x.Process.Id, x.User)); EventMessageBus.Current.GetEvent <IStartSystemProcess>(Source).Where(x => !autoRun && x.ProcessToBeStartedId != ProcessActions.NullProcess).Subscribe(x => StartProcess(x.ProcessToBeStartedId, x.User)); StartProcess(firstMsg.Process.Id, firstMsg.User); }
public static IEventActor GetOrCreateEventActor(this IUntypedActorContext system, string name, bool killOnFirstResponse = false) { var child = system.Child(name); return(child.Equals(ActorRefs.Nobody) ? EventActor.Create(system, name, killOnFirstResponse) : EventActor.From(child)); }
public LykkeLogBuilder(IUntypedActorContext context, string process, T trigger) { _context = context; _logLevel = LogLevel.Info; _process = string.IsNullOrEmpty(process) ? typeof(T).Name : process; _stopwatch = new Stopwatch(); _trigger = trigger; _stopwatch.Start(); }
public override IActorRef Build(IUntypedActorContext context, string name) { var router = new SmallestMailboxPool(_serviceSettings.NrOfTransactionMonitors); return(context.ActorOf ( context.DI().Props <TransactionMonitorActor>().WithRouter(router), name )); }
public EntityDataServiceSupervisor(ISystemProcess process, IProcessSystemMessage msg) : base(process) { ctx = Context; foreach (var itm in entityEvents) { this.GetType() .GetMethod("CreateEntityActor") .MakeGenericMethod(itm.Key) .Invoke(this, new object[] { itm.Value, process, msg }); } }
public static IActorRef ChildWithBackoffSupervision(this IUntypedActorContext context, Props childProps, string name, int minBackoff = 1, int maxBackoff = 3) { return(context.ActorOf( Props.Create(() => new BackoffSupervisor(childProps, name, TimeSpan.FromSeconds(minBackoff), TimeSpan.FromSeconds(maxBackoff), 0.1), SupervisorStrategy.StoppingStrategy))); }
protected virtual IActorRef FindOrCreate(string aggregateId, IUntypedActorContext context) { var aggregate = Context.Child(aggregateId); if (aggregate.IsNobody()) { aggregate = context.ActorOf(Props.Create(() => new Projector <TJournal, TProjection, TProjectionId, TProjectionContext>(aggregateId, _repository, _eventMap)), aggregateId); } return(aggregate); }
public static ActorSelection ActorSelection(this IUntypedActorContext context, ActorMetadata actor, ActorPathType path = ActorPathType.Absolute) { return(context.ActorSelection(actor.Path)); //switch (path) //{ // case ActorPathType.Absolute: // return context.ActorSelection(actor.Path); // case ActorPathType.Relative: // return context.ActorSelection(actor.RelativeUri); // default: // return context.ActorSelection(actor.AbsoluteUri); //} }
public void Handle( IUntypedActorContext actorContext, IActorRef repository, TProjectionContext projectionContext, IActorRef manager, EventEnvelope eventEnvelope) { var projector = FindOrCreate(eventEnvelope.PersistenceId, actorContext); projector.Tell(new ProjectEvent <TProjectionContext> { Context = projectionContext, Event = eventEnvelope }); actorContext.GetLogger().Info("{0} - {1} - {2}", eventEnvelope.Event.GetType(), eventEnvelope.PersistenceId, eventEnvelope.SequenceNr); }
public static IActorRef ChildWithBackoffSupervision <T>(this IUntypedActorContext context, string name = nameof(T), int minBackoff = 1, int maxBackoff = 3) where T : ActorBase { var childProps = context.System.DI().Props <T>(); return(context.ActorOf( Props.Create(() => new BackoffSupervisor(childProps, name, TimeSpan.FromSeconds(minBackoff), TimeSpan.FromSeconds(maxBackoff), 0.1), SupervisorStrategy.StoppingStrategy))); }
public static Dictionary <EdiActorsEnum, IActorRef> CreateCoordinatorEdiChildrenActors( IUntypedActorContext context) { var actors = new Dictionary <EdiActorsEnum, IActorRef> { { EdiActorsEnum.IdentificadorPassagemDuplicadaEdiActor, context.ActorOf(Props.Create(() => new IdentificadorPassagemDuplicadaEdiActor()), ActorsPath.IdentificadorPassagemDuplicadaEdiActor.Name) } }; return(actors); }
public static Dictionary <ParkActorsEnum, IActorRef> CreateCoordinatorParkChildrenActors( IUntypedActorContext context) { var actors = new Dictionary <ParkActorsEnum, IActorRef> { { ParkActorsEnum.ValidarPassagemPendenteParkActor, context.ActorOf(Props.Create(() => new ValidarPassagemPendenteParkActor()), ActorsPath.ValidarPassagemPendenteParkActor.Name) } }; return(actors); }
public static IActorRef CreateActor(IUntypedActorContext context, Type actorType, string name) { var actorName = actorType.Name + "." + name; var actor = context.Child(actorName); if (!actor.Equals(ActorRefs.Nobody)) { return(actor); } var actorProps = context.DI().Props(actorType); actor = context.ActorOf(actorProps, actorName); return(actor); }
public BotActor() { ThisContext = Context; Bot.OnMessage += BotOnMessageReceived; Bot.OnMessageEdited += BotOnMessageReceived; Bot.OnCallbackQuery += BotOnCallbackQueryReceived; Bot.OnInlineQuery += BotOnInlineQueryReceived; Bot.OnInlineResultChosen += BotOnChosenInlineResultReceived; Bot.OnReceiveError += BotOnReceiveError; MqttActor = ThisContext.ActorOf(Props.Create(() => new MqttActor()), "MqttActor"); MqttActor.Tell(new MqttActorMessage.Start()); MqttActor.Tell(new MqttActorMessage.Subscribe(DeviceStatus)); MqttActor.Tell(new MqttActorMessage.Subscribe(LightStatus)); Receive <BotActorMessage.Start>(StartReceived, null); Receive <BotActorMessage.Stop>(StopReceived, null); Receive <BotActorMessage.SendTextMessage>(SendTextMessageReceived, null); Receive <MqttActorMessage.PayloadReceived>(MqttPayloadReceived, null); }
public EntityViewDataServiceSupervisor(ISystemProcess process, IProcessSystemMessage msg) : base(process) { try { ctx = Context; Parallel.ForEach(entityEvents, new ParallelOptions() { MaxDegreeOfParallelism = Environment.ProcessorCount }, (itm) => { this.GetType() .GetMethod("CreateEntityViewActor") .MakeGenericMethod(itm.Key) .Invoke(this, new object[] { itm.Value, process, msg }); }); } catch (Exception) { throw; } }
public MqttActor() { ThisContext = Context; Options = new ManagedMqttClientOptionsBuilder() .WithAutoReconnectDelay(TimeSpan.FromSeconds(10)) .WithClientOptions(new MqttClientOptionsBuilder() .WithProtocolVersion(MQTTnet.Serializer.MqttProtocolVersion.V311) .WithClientId(Environment.GetEnvironmentVariable("MqttClientId")) .WithTcpServer(Environment.GetEnvironmentVariable("MqttServer"), 1883) .WithCredentials(Environment.GetEnvironmentVariable("MqttUsername"), Environment.GetEnvironmentVariable("MqttPassword")) .WithCleanSession() .Build()) .Build(); MqttClient = new MqttFactory().CreateManagedMqttClient(); MqttClient.ApplicationMessageReceived += MqttClient_ApplicationMessageReceived; MqttClient.Connected += MqttClient_Connected; Receive <MqttActorMessage.Start>(StartReceived, null); Receive <MqttActorMessage.Subscribe>(SubscribeReceived, null); }
public ViewModelSupervisor(List <IViewModelInfo> processViewModelInfos, ISystemProcess process, ISystemStarted firstMsg) : base(process) { ProcessViewModelInfos = processViewModelInfos; ctx = Context; Task.Run(() => { ctx.ActorOf( Props.Create <ViewModelActor>(process) .WithRouter(new RoundRobinPool(1, new DefaultResizer(1, Environment.ProcessorCount, 1, .2, .3, .1, Environment.ProcessorCount))), "ViewModelActorEntityActor"); }); EventMessageBus.Current.GetEvent <ISystemProcessStarted>(Source).Subscribe(x => HandleProcessViews(x)); EventMessageBus.Current.GetEvent <IServiceStarted <IViewModelService> >(Source).Subscribe(x => { EventMessageBus.Current.Publish(new ServiceStarted <IViewModelSupervisor>(this, new StateEventInfo(process.Id, RevolutionData.Context.Actor.Events.ActorStarted), process, Source), Source); }); //HandleProcessViews(firstMsg); }
public ProcessActor(ICreateProcessActor msg) : base(msg.Process) { ctx = Context; EventMessageBus.Current.GetEvent <IProcessStateMessage <IEntityId> >(Source) .Where(x => x.Process.Id == msg.Process.Id) .Subscribe(x => SaveStateMessages(x)); EventMessageBus.Current.GetEvent <IRequestProcessState>(Source) .Where(x => x.Process.Id == msg.Process.Id) .Subscribe(x => HandleRequestState(x)); EventMessageBus.Current.GetEvent <IRequestProcessLog>(Source) .Where(x => x.Process.Id == msg.Process.Id) .Subscribe(x => HandleProcessLogRequest(x)); EventMessageBus.Current.GetEvent <IComplexEventLogCreated>(Source) .Where(x => x.Process.Id == msg.Process.Id) .Subscribe(x => HandleComplexEventLog(x)); EventMessageBus.Current.GetEvent <IServiceStarted <IComplexEventService> >(Source) .Where(x => x.Process.Id == msg.Process.Id) .Subscribe(x => NotifyServiceStarted(x)); EventMessageBus.Current.GetEvent <ICleanUpSystemProcess>(Source).Where(x => x.ProcessToBeCleanedUpId == Process.Id).Subscribe(x => Self.GracefulStop(TimeSpan.FromSeconds((double)EventTimeOut.ShortWait))); EventMessageBus.Current.GetEvent <IServiceStarted <IProcessService> >(Source) .Where(x => x.Process.Id == msg.Process.Id) .Subscribe(q => { EventMessageBus.Current.GetEvent <IProcessSystemMessage>(Source) .Where( x => x.Process.Id == Process.Id && x.MachineInfo.MachineName == Process.MachineInfo.MachineName) .Subscribe(z => HandleProcessEvents(z)); }); _complexEvents = new ReadOnlyCollection <IComplexEventAction>(msg.ComplexEvents); StartActors(_complexEvents); }
public static void CreateIfNotExists <TActor>(this Dictionary <string, IActorRef> actors, IUntypedActorContext context, string key) where TActor : ActorBase, new() { if (!actors.ContainsKey(key)) { IActorRef actorRef = context.ActorOf(Props.Create(() => new TActor()), key); actors.Add(key, actorRef); } }
public static Dictionary <EdiActorsEnum, IActorRef> CreateValidadorPassagemEdiChildrenActors(IUntypedActorContext context) { var actors = new Dictionary <EdiActorsEnum, IActorRef> { { EdiActorsEnum.GeradorPassagemReprovadaEdiActor, context.ActorOf(Props.Create(() => new GeradorPassagemReprovadaEdiActor()), ActorsPath.GeradorPassagemReprovadaEdiActor.Name) }, { EdiActorsEnum.ValidadorPassagemSistemaEdiActor, context.ActorOf(Props.Create(() => new ValidadorPassagemSistemaEdiActor()), ActorsPath.ValidadorPassagemSistemaEdiActor.Name) } }; return(actors); }
public EntityActorMessageContext(IUntypedActorContext actorContext) { ActorContext = actorContext ?? throw new ArgumentNullException(nameof(actorContext)); }
public void CreateNotebook(IUntypedActorContext context, DirectoryInfo directory) { var actor = context.ActorOf(ActorRegistry.Notebook); CreateNotebook(actor, directory); }
public HubConnection(IUntypedActorContext parentContext) { _parentContext = parentContext; Receive<Tcp.Received>(received => { var messages = MessageSeriliazer.Deserialize(Context.System, received.Data); messages.ForEach(Self.Forward); }); Receive<Tcp.ConnectionClosed>(closed => { _log.Info($"Client connection {Self.Path.Name} was closed. Reason: {closed.GetErrorCause()}"); foreach (var hubPair in _hubs.AllMinToMax) { var name = hubPair.Key; var hub = hubPair.Value; hub.Forward(new Signal.Leave(name)); } Context.Stop(Self); }); Receive<Signal.Join>(join => { if (_hubs.Contains(join.HubName)) return; var hub = _parentContext.Child(join.HubName); if (hub.IsNobody()) { Sender.Tell(WriteObject(new Signal.NotFound(join.HubName))); return; } _hubs = _hubs.Add(join.HubName, hub); hub.Forward(join); }); Receive<Signal.Leave>(leave => { if (!_hubs.Contains(leave.HubName)) return; var hub = _parentContext.Child(leave.HubName); if (hub.IsNobody()) { Sender.Tell(WriteObject(new Signal.NotFound(leave.HubName))); return; } _hubs = _hubs.Remove(leave.HubName); hub.Forward(leave); }); Receive<Signal.Broadcast>(broadcast => { var hub = _parentContext.Child(broadcast.HubName); if (hub.IsNobody()) { Sender.Tell(WriteObject(new Signal.NotFound(broadcast.HubName))); return; } hub.Forward(broadcast); }); }