internal ActorSystem(string name, ActorsConfiguration?config) { Config = config ?? ActorsConfiguration.CreateDefault(); Name = ActorPath.Sanitize(name); Location = new ActorPath($"{ActorPath.ProtocolName}://{Name}/"); Actors = new Dictionary <ActorPath, ActorContainer>(); CancelToken = new CancellationTokenSource(); Scheduler = new Scheduler(); Scheduler.AssignSystem(this); Root = new RootSupervisor(this); Root.Populate(this, ActorReferences.Nobody, Location); var rootcontainer = new ActorContainer(new ActorSchematic(() => new RootSupervisor(this)), Location.Name, Root); Actors.Add(Location, rootcontainer); Root.CallOnCreate(); Log = new ActorLogger(Root); Lost = new LostLetters(this); Lost.Populate(this, new LocalActorReference(this, Root.Path), new ActorPath(Location.Path, "lost-letters")); var lostcontainer = new ActorContainer(new ActorSchematic(() => new LostLetters(this)), "lost-letters", Lost); Actors.Add(Lost.Path, lostcontainer); Lost.CallOnCreate(); if (!Config.ManuallyStartScheduler) { Scheduler.Start(); } SystemCount++; }
public static void Iniciar() { _log = new ActorLogger(); //Cria o ActorSystem ActorSystem = ActorSystem.Create(ActorsPath.ActorSystem.Name); //Cria o coordenador no contexto _actorCoordinator = ActorsParkCreator.CreateCoordinator(ActorSystem); _log.Info("Iniciando sistema de atores..."); }
private void HandleConstructSqlQueryMessage(HeliumConstructSqlQueryMessage requestMessage) { ActorLogger.Log(LogLevel.InfoLevel, $"Constructing {requestMessage.HeliumAction} SQL Query for {requestMessage.DataModel.GetType().Name}"); var sqlQuery = ConstructSelectStatement(requestMessage.DataModel); var resultMessage = new HeliumConstructSqlQueryResultMessage(requestMessage.HeliumAction, sqlQuery); resultMessage.AddStateData(requestMessage.MessageStateData); Sender.Tell(resultMessage, Self); }
internal void Populate(ActorSystem system, IActorReference parent, ActorPath path) { Path = path; ActorLog = new ActorLogger(this); System = system; Self = new LocalActorReference(system, path); Stash = new MessageStash(system, this); Handlers = new HandlerService(system, this); InternalParent = parent; InternalChildren = new List <IActorReference>(); InternalLog = ActorLog; }
public Actor() { Path = null !; ActorLog = null !; System = null !; InternalSender = null !; Self = null !; Stash = null !; Handlers = null !; InternalParent = null !; InternalChildren = null !; InternalLog = null !; }
/// <summary> /// Helium File Connection String Actor constructor /// </summary> /// <param name="databaseSettings"></param> public HeliumFileConnectionStringActor(IThuriaDatabaseSettings databaseSettings) { if (databaseSettings == null) { throw new ArgumentNullException(nameof(databaseSettings)); } Receive <HeliumGetConnectionStringMessage>(message => { var connectionString = databaseSettings.GetConnectionString(message.DbContextName); ActorLogger.Log(LogLevel.InfoLevel, $"Retrieved Connection String Context: {message.DbContextName} String: {connectionString}"); var resultMessage = new HeliumGetConnectionStringResultMessage(connectionString); resultMessage.AddStateData(message.MessageStateData); Sender.Tell(resultMessage); }); }
private void HandleHeliumAction(HeliumActionMessage actionMessage) { ActorLogger.Log(LogLevel.InfoLevel, $"Starting Helium Action : {actionMessage.HeliumAction}"); StartHeliumActionProcessing(actionMessage); }
/// <summary> /// Unhandled message handler /// </summary> /// <param name="message"></param> protected override void Unhandled(object message) { ActorLogger.Log(LogLevel.WarningLevel, $"Unhandled message received -> {message}"); base.Unhandled(message); }
/// <summary> /// Make sre the actor is in a state to Perform the required action /// </summary> protected virtual void ReadyToPerformAction() { ActorLogger.Log(LogLevel.InfoLevel, $"Helium Actor ready to process {HeliumAction} Action"); Receive <HeliumActionMessage>(HandleHeliumAction, message => message.HeliumAction == HeliumAction); }