/// <summary> /// Creates simple actor from config /// </summary> /// <param name="context">Current actor context (will create child actor)</param> /// <param name="actorConfig">Configuration to create from</param> /// <param name="componentContext">Dependency resolver</param> /// <param name="currentPath">Parent (current) actor path</param> /// <param name="pathName">New actor's path name</param> protected override void CreateSimpleActor( IActorContext context, Config actorConfig, IComponentContext componentContext, string currentPath, string pathName) { var childTypeName = actorConfig.GetString("type"); if (string.IsNullOrWhiteSpace(childTypeName)) { return; } var type = Type.GetType(childTypeName); if (type != null) { context.GetLogger() .Info( // ReSharper disable FormatStringProblem "{Type}: {NameSpaceName} initializing {ActorType} on {PathString}", // ReSharper restore FormatStringProblem typeof(NameSpaceActor).Name, currentPath, type.Name, pathName); if (type == typeof(NameSpaceActor) || type == typeof(NameSpaceForwarder)) { // this is done for tests, otherwise it would lead to CircularDependencyException context.ActorOf(Props.Create(() => new NameSpaceForwarder(componentContext, this.testActor)), pathName); } else { context.ActorOf(Context.System.DI().Props(type), pathName); } } else { context.GetLogger() .Error( // ReSharper disable FormatStringProblem "{Type}: {ClassTypeString} was not found for actor {NameSpaceName}/{PathString}", // ReSharper restore FormatStringProblem typeof(NameSpaceActor).Name, childTypeName, currentPath, pathName); } }
/// <summary> /// Creates simple actor from config /// </summary> /// <param name="context">Current actor context (will create child actor)</param> /// <param name="actorConfig">Configuration to create from</param> /// <param name="windsorContainer">Dependency resolver</param> /// <param name="currentPath">Parent (current) actor path</param> /// <param name="pathName">New actor's path name</param> protected override void CreateSimpleActor( IActorContext context, Config actorConfig, IWindsorContainer windsorContainer, string currentPath, string pathName) { var childTypeName = actorConfig.GetString("type"); if (string.IsNullOrWhiteSpace(childTypeName)) { return; } var type = Type.GetType(childTypeName); if (type != null) { context.GetLogger() .Info( // ReSharper disable FormatStringProblem "{Type}: {NameSpaceName} initializing {ActorType} on {PathString}", // ReSharper restore FormatStringProblem typeof(NameSpaceActor).Name, currentPath, type.Name, pathName); if (type == typeof(NameSpaceActor) || type == typeof(NameSpaceForwarder)) { // this is done for tests, otherwise it would lead to CircularDependencyException context.ActorOf(Props.Create(() => new NameSpaceForwarder(windsorContainer, this.testActor)), pathName); } else { context.ActorOf(Context.System.DI().Props(type), pathName); } } else { context.GetLogger() .Error( // ReSharper disable FormatStringProblem "{Type}: {ClassTypeString} was not found for actor {NameSpaceName}/{PathString}", // ReSharper restore FormatStringProblem typeof(NameSpaceActor).Name, childTypeName, currentPath, pathName); } }
public static IActorRef GetOrAdd <TActor>(this IActorContext context, string?name) where TActor : ActorBase, new() { var child = context.Child(name); return(child.Equals(ActorRefs.Nobody) ? context.ActorOf <TActor>(name) : child); }
public override Routee NewRoutee(Props routeeProps, IActorContext context) { var name = "c" + _childNameCounter.GetAndIncrement(); var actorRef = context.ActorOf(EnrichWithPoolDispatcher(routeeProps, context), name); return(new ActorRefRoutee(actorRef)); }
public IActorRef CreateResourceHarvesterActor(IActorContext actorContext, IActorRef villagerActor) { var props = Props.Create <ResourceHarvesterActor>(actorContext.System.Scheduler, villagerActor); var resourceHarvesterRoutine = actorContext.ActorOf(props); return(resourceHarvesterRoutine); }
public IActorRef CreateResourceHarvesterActor(IActorContext actorContext, IActorRef villagerActor) { var props = Props.Create <ConsoleResourceHarvesterActor>(actorContext.System.Scheduler, villagerActor); var consoleActor = actorContext.ActorOf(props); return(consoleActor); }
private static IActorRef CreateSession(IActorContext context, Socket socket) { var logger = LogManager.GetLogger($"Client({socket.RemoteEndPoint.ToString()})"); return(context.ActorOf(Props.Create(() => new ClientSession( logger, socket, _tcpConnectionSettings, CreateInitialActor)))); }
/// <summary> /// Creates cluster sharding proxy actor from config /// </summary> /// <param name="context">Current actor context (will create child actor)</param> /// <param name="actorConfig">Configuration to create from</param> /// <param name="container">Dependency resolver</param> /// <param name="pathName">New actor's path name</param> protected virtual void CreateShardingProxyActor( IActorContext context, Config actorConfig, IComponentContext container, string pathName) { context.ActorOf(Props.Create(() => new ShardingProxyWrappperActor(container, actorConfig)), pathName); }
public IActorRef Create(IActorContext actorContext, ActorSetUpOptions options = null) { var props = actorContext.DI().Props(Actortype); props = PrepareProps(options, props); return(actorContext.ActorOf(props, name: ActorName)); }
/// <summary> /// Creates cluster sharding proxy actor from config /// </summary> /// <param name="context">Current actor context (will create child actor)</param> /// <param name="actorConfig">Configuration to create from</param> /// <param name="windsorContainer">Dependency resolver</param> /// <param name="pathName">New actor's path name</param> protected virtual void CreateShardingProxyActor( IActorContext context, Config actorConfig, IWindsorContainer windsorContainer, string pathName) { context.ActorOf(Props.Create(() => new ShardingProxyWrappperActor(windsorContainer, actorConfig)), pathName); }
private static Tuple <IActorRef, Type>[] CreateInitialActor(IActorContext context, Socket socket) { return(new[] { Tuple.Create(context.ActorOf(Props.Create(() => new ServerActor())), typeof(IServer)) }); }
private static Tuple<IActorRef, Type>[] CreateInitialActor(IActorContext context, Socket socket) { return new[] { Tuple.Create(context.ActorOf(Props.Create(() => new ServerActor())), typeof(IServer)) }; }
private Tuple <IActorRef, TaggedType[], ActorBindingFlags>[] CreateInitialActor(IActorContext context) => new[] { Tuple.Create( context.ActorOf(Props.Create(() => new UserLoginActor(_clusterContext, context.Self.Cast <ActorBoundChannelRef>(), new IPEndPoint(IPAddress.None, 0)))), new TaggedType[] { typeof(IUserLogin) }, (ActorBindingFlags)0) };
private Tuple<IActorRef, TaggedType[], ActorBindingFlags>[] CreateInitialActor(IActorContext context) => new[] { Tuple.Create( context.ActorOf(Props.Create(() => new UserLoginActor(_clusterContext, context.Self.Cast<ActorBoundChannelRef>(), new IPEndPoint(IPAddress.None, 0)))), new TaggedType[] { typeof(IUserLogin) }, (ActorBindingFlags)0) };
public static IActorRef AskFor <T>( this IActorRef target , object message , IActorContext context , TimeSpan?timeout = null) { var props = TypedAsk <T> .Props(target, message, context.Self, timeout); return(context.ActorOf(props)); }
private static IActorRef CreateChildActor(IActorContext context, Type actorType, ActorSetUpOptions options) { var props = context.DI().Props(actorType); props = SelectableActor.PrepareProps(options, props); var actorRef = context.ActorOf(props, SelectableActor.GetActorNameByType(null, actorType)); return(actorRef); }
private Tuple <IActorRef, TaggedType[], ActorBindingFlags>[] CreateInitialActor(IActorContext context) { return(new[] { Tuple.Create( context.ActorOf(Props.Create(() => new UserLoginActor(context.Self))), new TaggedType[] { typeof(IUserLogin) }, ActorBindingFlags.CloseThenStop) }); }
private Tuple<IActorRef, TaggedType[], ActorBindingFlags>[] CreateInitialActor(IActorContext context) { return new[] { Tuple.Create( context.ActorOf(Props.Create(() => new UserLoginActor(context.Self))), new TaggedType[] { typeof(IUserLogin) }, ActorBindingFlags.CloseThenStop) }; }
private static IActorRef InstantiateQueryActor <T>(IDictionary <IActorRef, object> messages, IActorContext context, TimeSpan?timeout = null) { var props = TypedQuery <T> .Props(messages, context.Self, timeout); var actor = context.ActorOf(props); actor.Tell(RunTypedQuery.Instance); return(actor); }
public IActorRef Create(IActorContext context, IL4ConversationKey l4Key, IActorRef contractor, IPEndPoint sourceEndPoint, IPEndPoint destinationEndPoint, IActorRef l7ConversationStorageActor, Int64 timestampTicks) => context.ActorOf(L4ConversationTrackingActor.Props(l4Key, contractor, sourceEndPoint, destinationEndPoint, l7ConversationStorageActor) #if DEBUG , $"{l4Key.ToString()}_{timestampTicks}" #endif );
protected override async Task HandleReplayMessages(ReplayMessages req, OracleCommand command, IActorContext context) { var replaySettings = Setup.ReplayFilterSettings; var replyTo = replaySettings.IsEnabled ? context.ActorOf(ReplayFilter.Props(req.PersistentActor, replaySettings.Mode, replaySettings.WindowSize, replaySettings.MaxOldWriters, replaySettings.IsDebug)) : req.PersistentActor; var persistenceId = req.PersistenceId; NotifyNewPersistenceIdAdded(persistenceId); try { var highestSequenceNr = await ReadHighestSequenceNr(persistenceId, command); var toSequenceNr = Math.Min(req.ToSequenceNr, highestSequenceNr); command.CommandText = ByPersistenceIdSql; command.Parameters.Clear(); AddParameter(command, ":PersistenceId", OracleDbType.NVarchar2, persistenceId); AddParameter(command, ":FromSequenceNr", OracleDbType.Int64, req.FromSequenceNr); AddParameter(command, ":ToSequenceNr", OracleDbType.Int64, toSequenceNr); using (var reader = await command.ExecuteReaderAsync()) { var i = 0L; while (i++ < req.Max && await reader.ReadAsync()) { var persistent = ReadEvent(reader); if (persistent.IsDeleted) { continue; } foreach (var adaptedRepresentation in AdaptFromJournal(persistent)) { replyTo.Tell(new ReplayedMessage(adaptedRepresentation), ActorRefs.NoSender); } } } var response = new RecoverySuccess(highestSequenceNr); replyTo.Tell(response, ActorRefs.NoSender); } catch (Exception cause) { var response = new ReplayMessagesFailure(cause); replyTo.Tell(response, ActorRefs.NoSender); } }
/// <summary> /// TBD /// </summary> /// <param name="context">TBD</param> /// <param name="persistenceId">TBD</param> /// <param name="fromSequenceNr">TBD</param> /// <param name="toSequenceNr">TBD</param> /// <param name="max">TBD</param> /// <param name="recoveryCallback">TBD</param> /// <exception cref="TimeoutException"> /// This exception is thrown when the store has not been initialized. /// </exception> /// <returns>TBD</returns> public override Task ReplayMessagesAsync(IActorContext context, string persistenceId, long fromSequenceNr, long toSequenceNr, long max, Action <IPersistentRepresentation> recoveryCallback) { if (_store == null) { return(StoreNotInitialized <object>()); } var replayCompletionPromise = new TaskCompletionSource <object>(); var mediator = context.ActorOf(Props.Create(() => new ReplayMediator(recoveryCallback, replayCompletionPromise, Timeout)).WithDeploy(Deploy.Local)); _store.Tell(new AsyncWriteTarget.ReplayMessages(persistenceId, fromSequenceNr, toSequenceNr, max), mediator); return(replayCompletionPromise.Task); }
private async ValueTask <ConnectionOpened> CreateConnection(DnsEndPoint logicalAddress, DnsEndPoint physicalAddress, int connectionKey) { if (_log.IsDebugEnabled) { _log.Debug($"Connection for {logicalAddress} not found in cache"); } var targetBroker = $"{physicalAddress.Host}:{physicalAddress.Port}"; if (!logicalAddress.Equals(physicalAddress)) { targetBroker = $"{logicalAddress.Host}:{logicalAddress.Port}"; } var cnx = _context.ActorOf(Props.Create(() => new ClientCnx(_clientConfig, physicalAddress, targetBroker)), $"{targetBroker}{connectionKey}".ToAkkaNaming()); var ask = await cnx.Ask <AskResponse>(Connect.Instance); if (ask.Failed) { //in a situation where we cannot connect, and since this will be retried, //in order to avoid conflicting actor names, lets kill it _context.Stop(cnx); await Task.Delay(TimeSpan.FromSeconds(1)); throw ask.Exception; } var connection = ask.ConvertTo <ConnectionOpened>(); if (_pool.TryGetValue(_logicalEndpoint, out _)) { _pool[_logicalEndpoint][_randomKey] = connection; } else { _pool.Add(_logicalEndpoint, new Dictionary <int, ConnectionOpened> { { _randomKey, connection } }); } return(connection); }
public IActorRef ActorOf <TActor>(string name = null) where TActor : ActorBase { return(context.ActorOf(producer.Props(typeof(TActor)), name)); }
/// <summary> /// Creates cluster singleton proxy actor from config /// </summary> /// <param name="context">Current actor context (will create child actor)</param> /// <param name="actorConfig">Configuration to create from</param> /// <param name="currentPath">Parent (current) actor path</param> /// <param name="pathName">New actor's path name</param> protected virtual void CreateSingletonProxyActor( IActorContext context, Config actorConfig, string currentPath, string pathName) { var singletonName = actorConfig.GetString("singleton-name"); if (string.IsNullOrEmpty(singletonName)) { context.GetLogger() .Error( "{Type}: singleton-name was not defined for {NameSpaceName}/{PathString}", typeof(NameSpaceActor).Name, currentPath, pathName); return; } var singletonManagerPath = actorConfig.GetString("singleton-path"); if (string.IsNullOrEmpty(singletonName)) { context.GetLogger() .Error( "{Type}: singleton-path was not defined for {NameSpaceName}/{PathString}", typeof(NameSpaceActor).Name, currentPath, pathName); return; } var role = actorConfig.GetString("singleton-node-role"); if (string.IsNullOrEmpty(role)) { context.GetLogger() .Error( "{Type}: singleton-node-role was not defined for {NameSpaceName}/{PathString}", typeof(NameSpaceActor).Name, currentPath, pathName); return; } context.GetLogger() .Info( "{Type}: {NameSpaceName} initializing singleton proxy {SingletonManagerPath} / {SingletonName} for {PathString}", typeof(NameSpaceActor).Name, currentPath, singletonManagerPath, singletonName, pathName); context.ActorOf( ClusterSingletonProxy.Props( singletonManagerPath: singletonManagerPath, settings: new ClusterSingletonProxySettings( singletonName, role, actorConfig.GetTimeSpan("singleton-identification-interval", TimeSpan.FromSeconds(1), false), actorConfig.GetInt("buffer-size", 2048))), name: pathName); }
public static IActorRef GetOrAdd(this IActorContext context, string?name, Props props) { var child = context.Child(name); return(child.Equals(ActorRefs.Nobody) ? context.ActorOf(props, name) : child); }
/// <summary> /// Creates cluster singleton actor from config /// </summary> /// <param name="context">Current actor context (will create child actor)</param> /// <param name="actorConfig">Configuration to create from</param> /// <param name="currentPath">Parent (current) actor path</param> /// <param name="pathName">New actor's path name</param> protected virtual void CreateSingletonActor( IActorContext context, Config actorConfig, string currentPath, string pathName) { var childTypeName = actorConfig.GetString("type"); if (string.IsNullOrWhiteSpace(childTypeName)) { return; } var type = Type.GetType(childTypeName); if (type == null) { context.GetLogger() .Error( "{Type}: {ClassTypeString} was not found for actor {NameSpaceName}/{PathString}", typeof(NameSpaceActor).Name, childTypeName, currentPath, pathName); return; } var singletonName = actorConfig.GetString("singleton-name"); if (string.IsNullOrEmpty(singletonName)) { context.GetLogger() .Error( "{Type}: singleton-name was not defined for{NameSpaceName}/ {PathString}", typeof(NameSpaceActor).Name, currentPath, pathName); return; } var role = actorConfig.GetString("singleton-node-role"); if (string.IsNullOrEmpty(role)) { context.GetLogger() .Error( "{Type}: singleton-node-role was not defined for {NameSpaceName}/{PathString}", typeof(NameSpaceActor).Name, currentPath, pathName); return; } context.GetLogger() .Info( "{Type}: {NameSpaceName} initializing singleton {SingletonName} of type {ActorType} on {PathString}", typeof(NameSpaceActor).Name, currentPath, singletonName, type.Name, pathName); context.ActorOf( ClusterSingletonManager.Props( context.System.DI().Props(type), new ClusterSingletonManagerSettings( singletonName, role, actorConfig.GetTimeSpan("removal-margin", TimeSpan.FromSeconds(1), false), actorConfig.GetTimeSpan("handover-retry-interval", TimeSpan.FromSeconds(5), false))), pathName); }
public Routee NewRoutee(Props routeeProps, IActorContext context) { var routee = new ActorRefRoutee(context.ActorOf(EnrichWithPoolDispatcher(routeeProps, context))); return routee; }
private static IActorRef CreateSession(IActorContext context, Socket socket) { var logger = LogManager.GetLogger($"Client({socket.RemoteEndPoint.ToString()})"); return context.ActorOf(Props.Create(() => new ClientSession( logger, socket, _tcpConnectionSettings, CreateInitialActor))); }
public static Maybe <IActorRef> GetOrAdd(this IActorContext context, Maybe <string> name, Props props) => from realName in name from child in TryGetChild(context, name) select child.IsNobody() ? context.ActorOf(props, realName) : child;
public static IActorRef ActorOfDI <T>(this IActorContext actorContext, string name = null) where T : ActorBase { return(actorContext.ActorOf(actorContext.DI().Props <T>(), name)); }
/// <inheritdoc /> public IActorRef ActorOf <TActor>(IActorContext context, string name = null) where TActor : ActorBase { return(context.ActorOf(context.DI().Props <TActor>(), name)); }
public IActorRef CreateResourceHarvesterActor(IActorContext actorContext, IActorRef villagerActor) { var props = Props.Create<ConsoleResourceHarvesterActor>(actorContext.System.Scheduler, villagerActor); var consoleActor = actorContext.ActorOf(props); return consoleActor; }
/// <summary> /// Creates a new <see cref="Routee"/> configured to use the provided <paramref name="routeeProps"/> /// and the pool dispatcher if enabled. /// </summary> /// <param name="routeeProps">The <see cref="Actor.Props"/> to configure with the pool dispatcher.</param> /// <param name="context">The context for the provided <paramref name="routeeProps"/>.</param> /// <returns> /// A new <see cref="Routee"/> configured to use the provided <paramref name="routeeProps"/> /// and the pool dispatcher if enabled. /// </returns> internal virtual Routee NewRoutee(Props routeeProps, IActorContext context) { return(new ActorRefRoutee(context.ActorOf(EnrichWithPoolDispatcher(routeeProps, context)))); }
public IActorRef GetActor <TActor>(IActorContext context, string actorName) where TActor : ActorBase { return(context.ActorOf(context.DI().Props <TActor>(), actorName)); }
public virtual Routee NewRoutee(Props routeeProps, IActorContext context) { var routee = new ActorRefRoutee(context.ActorOf(EnrichWithPoolDispatcher(routeeProps, context))); return(routee); }
public IActorRef CreateResourceHarvesterActor(IActorContext actorContext, IActorRef villagerActor) { var props = Props.Create<ResourceHarvesterActor>(actorContext.System.Scheduler, villagerActor); var resourceHarvesterRoutine = actorContext.ActorOf(props); return resourceHarvesterRoutine; }
public IActorRef Create <TActor>(IActorContext context, string name) where TActor : ActorBase => context.ActorOf(GetProps <TActor>(context), name);
public override Routee NewRoutee(Props routeeProps, IActorContext context) { var name = "c" + _childNameCounter.GetAndIncrement(); var actorRef = context.ActorOf(EnrichWithPoolDispatcher(routeeProps, context), name); return new ActorRefRoutee(actorRef); }
public void CreateTable(IActorContext context, Guid gameToken) { Table = context.ActorOf(Props.Create(() => new GameTableActor(Player.Token, gameToken)), Player.Token.ToString()); }
private void HandleRestartEntities(IImmutableSet <EntityId> ids) { _context.ActorOf(RememberEntityStarter.Props(_context.Parent, TypeName, ShardId, ids, Settings, _context.Sender)); }