public Task <Akka.Actor.ActorPath> GetPath(Akka.Actor.ActorPath path) { var requestMessage = new RequestMessage { InvokePayload = new ISurrogate_PayloadTable.GetPath_Invoke { path = path } }; return(SendRequestAndReceive <Akka.Actor.ActorPath>(requestMessage)); }
void ISurrogate_NoReply.GetPath(Akka.Actor.ActorPath path) { var requestMessage = new RequestMessage { InvokePayload = new ISurrogate_PayloadTable.GetPath_Invoke { path = path } }; SendRequest(requestMessage); }
/// <summary> /// Actors the of. /// </summary> /// <param name="system">The system.</param> /// <param name="props">The props.</param> /// <param name="supervisor">The supervisor.</param> /// <param name="path">The path.</param> /// <param name="systemService">Is this a child actor under the system guardian?</param> /// <returns>InternalActorRef.</returns> public abstract InternalActorRef ActorOf(ActorSystem system, Props props, InternalActorRef supervisor, ActorPath path, bool systemService = false);
public FutureActorRef(TaskCompletionSource <object> result, ActorRef sender, Action unregister, ActorPath path) { _result = result; _sender = sender ?? ActorRef.NoSender; _unregister = unregister; _path = path; }
public abstract ActorSelection ActorSelection(ActorPath actorPath);
/// <summary> /// TBD /// </summary> /// <param name="provider">TBD</param> /// <param name="path">TBD</param> /// <param name="eventStream">TBD</param> public EmptyLocalActorRef(IActorRefProvider provider, ActorPath path, EventStream eventStream) { _provider = provider; _path = path; _eventStream = eventStream; }
public StoppedWithPath(ActorPath path) { Path = path; }
public DeadLetterActorRef(IActorRefProvider provider, ActorPath path, EventStream eventStream) : base(provider, path, eventStream) { _eventStream = eventStream; }
/// <summary> /// Initializes a new instance of the <see cref="ChildActorPath" /> class. /// </summary> /// <param name="parentPath"> The parent path. </param> /// <param name="name"> The name. </param> /// <param name="uid"> The uid. </param> public ChildActorPath(ActorPath parentPath, string name, long uid) : base(parentPath, name, uid) { _name = name; _parent = parentPath; }
public LocalActorRef(ActorPath path, ActorCell context) { Path = path; Cell = context; }
/// <summary> /// Check if the passed `otherPath` is the same as IgnoreActorRef.path /// </summary> /// <param name="otherPath"></param> /// <returns></returns> public static bool IsIgnoreRefPath(ActorPath otherPath) => path.Equals(otherPath);
/// <summary> /// Initializes a new instance of the <see cref="ChildActorPath" /> class. /// </summary> /// <param name="parentPath">The parent path.</param> /// <param name="name">The name.</param> /// <param name="uid">The uid.</param> public ChildActorPath(ActorPath parentPath, string name, long uid) : base(parentPath, name, 0) { this.name = name; parent = parentPath; }
//TODO: real akka does this in the RoutedActorRef //Keep this here for now? public static ActorCell NewRouterCell(ActorSystem system, InternalActorRef supervisor, ActorPath path, Props props, Mailbox mailbox, Deploy deploy) { var routerProps = Props.Empty.WithDeploy(deploy); var routeeProps = props.WithRouter(RouterConfig.NoRouter); if (routerProps.RouterConfig is Pool) { var p = routerProps.RouterConfig.AsInstanceOf <Pool>(); if (p.Resizer != null) { //if there is a resizer, use ResizablePoolCell return(new ResizablePoolCell(system, supervisor, routerProps, routeeProps, path, mailbox, p)); } } //Use RoutedActorCell for all other routers return(new RoutedActorCell(system, supervisor, routerProps, routeeProps, path, mailbox)); }
/// <summary> /// Resolves the actor reference. /// </summary> /// <param name="actorPath">The actor path.</param> /// <returns>ActorRef.</returns> public abstract ActorRef ResolveActorRef(ActorPath actorPath);
//This mimics what's done in Akka`s construction of an LocalActorRef. //The actorCell is created in the overridable newActorCell() during creation of the instance. //Since we don't want calls to virtual members in C# we must supply it. // //This is the code from Akka: // private[akka] class LocalActorRef private[akka] ( // _system: ActorSystemImpl, // _props: Props, // _dispatcher: MessageDispatcher, // _mailboxType: MailboxType, // _supervisor: InternalActorRef, // override val path: ActorPath) extends ActorRefWithCell with LocalRef { // private val actorCell: ActorCell = newActorCell(_system, this, _props, _dispatcher, _supervisor) // actorCell.init(sendSupervise = true, _mailboxType) // ... // } public LocalActorRef(ActorSystemImpl system, Props props, MessageDispatcher dispatcher, MailboxType mailboxType, IInternalActorRef supervisor, ActorPath path) { _system = system; _props = props; _dispatcher = dispatcher; MailboxType = mailboxType; _supervisor = supervisor; _path = path; /* * Safe publication of this class’s fields is guaranteed by Mailbox.SetActor() * which is called indirectly from ActorCell.init() (if you’re wondering why * this is at all important, remember that under the CLR readonly fields are only * frozen at the _end_ of the constructor, but we are publishing “this” before * that is reached). * This means that the result of NewActorCell needs to be written to the field * _cell before we call init and start, since we can start using "this" * object from another thread as soon as we run init. */ // ReSharper disable once VirtualMemberCallInContructor _cell = NewActorCell(_system, this, _props, _dispatcher, _supervisor); // _cell needs to be assigned before Init is called. _cell.Init(true, MailboxType); }
private static async Task <object> Ask(ICanTell self, object message, IActorRefProvider provider, TimeSpan?timeout, CancellationToken cancellationToken) { TaskCompletionSource <object> result; if (isRunContinuationsAsynchronouslyAvailable) { result = new TaskCompletionSource <object>((TaskCreationOptions)RunContinuationsAsynchronously); } else { result = new TaskCompletionSource <object>(); } CancellationTokenSource timeoutCancellation = null; timeout = timeout ?? provider.Settings.AskTimeout; var ctrList = new List <CancellationTokenRegistration>(2); if (timeout != Timeout.InfiniteTimeSpan && timeout.Value > default(TimeSpan)) { timeoutCancellation = new CancellationTokenSource(); ctrList.Add(timeoutCancellation.Token.Register(() => { result.TrySetException(new AskTimeoutException($"Timeout after {timeout} seconds")); })); timeoutCancellation.CancelAfter(timeout.Value); } if (cancellationToken.CanBeCanceled) { ctrList.Add(cancellationToken.Register(() => result.TrySetCanceled())); } //create a new tempcontainer path ActorPath path = provider.TempPath(); var future = new FutureActorRef(result, () => { }, path, isRunContinuationsAsynchronouslyAvailable); //The future actor needs to be registered in the temp container provider.RegisterTempActor(future, path); self.Tell(message, future); try { return(await result.Task); } finally { //callback to unregister from tempcontainer provider.UnregisterTempActor(path); for (var i = 0; i < ctrList.Count; i++) { ctrList[i].Dispose(); } if (timeoutCancellation != null) { timeoutCancellation.Dispose(); } } }
public InternalActorRef ActorOf(ActorSystemImpl system, Props props, InternalActorRef supervisor, ActorPath path, bool systemService, Deploy deploy, bool lookupDeploy, bool async) { //TODO: This does not match Akka's ActorOf at all Deploy configDeploy = _system.Provider.Deployer.Lookup(path); deploy = configDeploy ?? props.Deploy ?? Deploy.None; if (deploy.Mailbox != null) { props = props.WithMailbox(deploy.Mailbox); } if (deploy.Dispatcher != null) { props = props.WithDispatcher(deploy.Dispatcher); } if (deploy.Scope is RemoteScope) { } if (string.IsNullOrEmpty(props.Mailbox)) { // throw new NotSupportedException("Mailbox can not be configured as null or empty"); } if (string.IsNullOrEmpty(props.Dispatcher)) { //TODO: fix this.. // throw new NotSupportedException("Dispatcher can not be configured as null or empty"); } //TODO: how should this be dealt with? //akka simply passes the "deploy" var from remote daemon to ActorOf //so it atleast seems like they ignore if remote scope is provided here. //leaving this for now since it does work //if (props.Deploy != null && props.Deploy.Scope is RemoteScope) //{ // throw new NotSupportedException("LocalActorRefProvider can not deploy remote"); //} if (props.RouterConfig is NoRouter || props.RouterConfig == null) { props = props.WithDeploy(deploy); var dispatcher = system.Dispatchers.FromConfig(props.Dispatcher); var mailbox = _system.Mailboxes.FromConfig(props.Mailbox); //TODO: Should be: system.mailboxes.getMailboxType(props2, dispatcher.configurator.config) if (async) { var reActorRef = new RepointableActorRef(system, props, dispatcher, () => mailbox, supervisor, path); reActorRef.Initialize(async: true); return(reActorRef); } return(new LocalActorRef(system, props, dispatcher, () => mailbox, supervisor, path)); } else { //if no Router config value was specified, override with procedural input if (deploy.RouterConfig is NoRouter) { deploy = deploy.WithRouterConfig(props.RouterConfig); } var routerDispatcher = system.Dispatchers.FromConfig(props.RouterConfig.RouterDispatcher); var routerMailbox = _system.Mailboxes.FromConfig(props.Mailbox); //TODO: Should be val routerMailbox = system.mailboxes.getMailboxType(routerProps, routerDispatcher.configurator.config) // routers use context.actorOf() to create the routees, which does not allow us to pass // these through, but obtain them here for early verification var routerProps = Props.Empty.WithDeploy(deploy); var routeeProps = props.WithRouter(RouterConfig.NoRouter); var routedActorRef = new RoutedActorRef(system, routerProps, routerDispatcher, () => routerMailbox, routeeProps, supervisor, path); routedActorRef.Initialize(async); return(routedActorRef); } }
public RepointableActorRef(ActorSystemImpl system, Props props, MessageDispatcher dispatcher, Func <Mailbox> createMailbox, InternalActorRef supervisor, ActorPath path) { _system = system; _props = props; _dispatcher = dispatcher; _createMailbox = createMailbox; _supervisor = supervisor; _path = path; }
/// <inheritdoc/> public override int CompareTo(ActorPath other) { return(InternalCompareTo(this, other)); }
public ActorSelection ActorSelection(ActorPath actorPath) { ActorRef actorRef = System.Provider.ResolveActorRef(actorPath); return(new ActorSelection(actorRef, "")); }
/// <summary> /// Actor factory with create-only semantics: will create an actor as /// described by <paramref name="props" /> with the given <paramref name="supervisor" /> and <paramref name="path" /> (may be different /// in case of remote supervision). If <paramref name="systemService" /> is true, deployment is /// bypassed (local-only). If a value for<paramref name="deploy" /> is passed in, it should be /// regarded as taking precedence over the nominally applicable settings, /// but it should be overridable from external configuration; the lookup of /// the latter can be suppressed by setting "lookupDeploy" to "false". /// </summary> /// <param name="system">TBD</param> /// <param name="props">TBD</param> /// <param name="supervisor">TBD</param> /// <param name="path">TBD</param> /// <param name="systemService">TBD</param> /// <param name="deploy">TBD</param> /// <param name="lookupDeploy">TBD</param> /// <param name="async">TBD</param> /// <exception cref="ConfigurationException"> /// This exception can be thrown for a number of reasons. The following are some examples: /// <dl> /// <dt><b>non-routers</b></dt> /// <dd>The dispatcher in the given <paramref name="props"/> is not configured for the given <paramref name="path"/>.</dd> /// <dd>or</dd> /// <dd>There was a configuration problem while creating the given <paramref name="path"/> with the dispatcher and mailbox from the given <paramref name="props"/></dd> /// <dt><b>routers</b></dt> /// <dd>The dispatcher in the given <paramref name="props"/> is not configured for routees of the given <paramref name="path"/></dd> /// <dd>or</dd> /// <dd>The dispatcher in the given <paramref name="props"/> is not configured for router of the given <paramref name="path"/></dd> /// <dd>or</dd> /// <dd>$There was a configuration problem while creating the given <paramref name="path"/> with router dispatcher and mailbox and routee dispatcher and mailbox.</dd> /// </dl> /// </exception> /// <returns>TBD</returns> public IInternalActorRef ActorOf(ActorSystemImpl system, Props props, IInternalActorRef supervisor, ActorPath path, bool systemService, Deploy deploy, bool lookupDeploy, bool async) { if (props.Deploy.RouterConfig is NoRouter) { if (Settings.DebugRouterMisconfiguration) { var d = Deployer.Lookup(path); if (d != null && !(d.RouterConfig is NoRouter)) { Log.Warning("Configuration says that [{0}] should be a router, but code disagrees. Remove the config or add a RouterConfig to its Props.", path); } } var props2 = props; // mailbox and dispatcher defined in deploy should override props var propsDeploy = lookupDeploy ? Deployer.Lookup(path) : deploy; if (propsDeploy != null) { if (propsDeploy.Mailbox != Deploy.NoMailboxGiven) { props2 = props2.WithMailbox(propsDeploy.Mailbox); } if (propsDeploy.Dispatcher != Deploy.NoDispatcherGiven) { props2 = props2.WithDispatcher(propsDeploy.Dispatcher); } } if (!system.Dispatchers.HasDispatcher(props2.Dispatcher)) { throw new ConfigurationException($"Dispatcher [{props2.Dispatcher}] not configured for path {path}"); } try { // for consistency we check configuration of dispatcher and mailbox locally var dispatcher = _system.Dispatchers.Lookup(props2.Dispatcher); var mailboxType = _system.Mailboxes.GetMailboxType(props2, dispatcher.Configurator.Config); if (async) { return (new RepointableActorRef(system, props2, dispatcher, mailboxType, supervisor, path).Initialize(async)); } return(new LocalActorRef(system, props2, dispatcher, mailboxType, supervisor, path)); } catch (Exception ex) { throw new ConfigurationException( $"Configuration problem while creating [{path}] with dispatcher [{props.Dispatcher}] and mailbox [{props.Mailbox}]", ex); } } else //routers!!! { var lookup = (lookupDeploy ? Deployer.Lookup(path) : null) ?? Deploy.None; var fromProps = new List <Deploy>() { props.Deploy, deploy, lookup }; var d = fromProps.Where(x => x != null).Aggregate((deploy1, deploy2) => deploy2.WithFallback(deploy1)); var p = props.WithRouter(d.RouterConfig); if (!system.Dispatchers.HasDispatcher(p.Dispatcher)) { throw new ConfigurationException($"Dispatcher [{p.Dispatcher}] not configured for routees of path [{path}]"); } if (!system.Dispatchers.HasDispatcher(d.RouterConfig.RouterDispatcher)) { throw new ConfigurationException($"Dispatcher [{p.RouterConfig.RouterDispatcher}] not configured for router of path [{path}]"); } var routerProps = Props.Empty.WithRouter(p.Deploy.RouterConfig).WithDispatcher(p.RouterConfig.RouterDispatcher); var routeeProps = props.WithRouter(NoRouter.Instance); try { var routerDispatcher = system.Dispatchers.Lookup(p.RouterConfig.RouterDispatcher); var routerMailbox = system.Mailboxes.GetMailboxType(routerProps, routerDispatcher.Configurator.Config); // routers use context.actorOf() to create the routees, which does not allow us to pass // these through, but obtain them here for early verification var routeeDispatcher = system.Dispatchers.Lookup(p.Dispatcher); var routedActorRef = new RoutedActorRef(system, routerProps, routerDispatcher, routerMailbox, routeeProps, supervisor, path); routedActorRef.Initialize(async); return(routedActorRef); } catch (Exception ex) { throw new ConfigurationException( $"Configuration problem while creating [{path}] with router dispatcher [{routerProps.Dispatcher}] and mailbox [{routerProps.Mailbox}] and routee dispatcher [{routeeProps.Dispatcher}] and mailbox [{routeeProps.Mailbox}].", ex); } } }
public ActorCell(ActorSystem system, InternalActorRef supervisor, Props props, ActorPath path, Mailbox mailbox) { Parent = supervisor; System = system; Self = new LocalActorRef(path, this); Props = props; Dispatcher = System.Dispatchers.FromConfig(props.Dispatcher); mailbox.Setup(Dispatcher); Mailbox = mailbox; Mailbox.ActorCell = this; }
/// <summary> /// Construct an <see cref="Akka.Actor.ActorSelection"/> from the given path, which is /// parsed for wildcards (these are replaced by regular expressions /// internally). No attempt is made to verify the existence of any part of /// the supplied path, it is recommended to send a message and gather the /// replies in order to resolve the matching set of actors. /// </summary> /// <param name="actorPath">TBD</param> /// <param name="system">TBD</param> /// <returns>TBD</returns> public static ActorSelection ActorSelection(ActorPath actorPath, ActorSystem system) { return(new ActorSelection(((ActorSystemImpl)system).Provider.RootGuardianAt(actorPath.Address), actorPath.Elements)); }
public ActorSelection ActorSelection(ActorPath path) { return(ActorRefFactoryShared.ActorSelection(path, System)); }
public ActorSelection ActorSelection(Akka.Actor.ActorPath actorPath) { return(_actorSystem.ActorSelection(actorPath)); }
//This mimics what's done in Akka`s construction of an LocalActorRef. //The actorCell is created in the overridable newActorCell() during creation of the instance. //Since we don't want calls to virtual members in C# we must supply it. // //This is the code from Akka: // private[akka] class LocalActorRef private[akka] ( // _system: ActorSystemImpl, // _props: Props, // _dispatcher: MessageDispatcher, // _mailboxType: MailboxType, // _supervisor: InternalActorRef, // override val path: ActorPath) extends ActorRefWithCell with LocalRef { // private val actorCell: ActorCell = newActorCell(_system, this, _props, _dispatcher, _supervisor) // actorCell.init(sendSupervise = true, _mailboxType) // ... // } public LocalActorRef(ActorSystem system, Props props, MessageDispatcher dispatcher, Func <Mailbox> createMailbox, InternalActorRef supervisor, ActorPath path) //TODO: switch from Func<Mailbox> createMailbox to MailboxType mailboxType : this(system, props, dispatcher, createMailbox, supervisor, path, self => { var cell = new ActorCell(system, self, props, dispatcher, supervisor); cell.Init(sendSupervise: true, createMailbox: createMailbox); return(cell); }) { //Intentionally left blank }
public RepointableActorRef(ActorSystemImpl system, Props props, MessageDispatcher dispatcher, MailboxType mailboxType, IInternalActorRef supervisor, ActorPath path) { System = system; Props = props; Dispatcher = dispatcher; MailboxType = mailboxType; Supervisor = supervisor; _path = path; }
/// <summary> /// Inheritors should only call this constructor /// </summary> internal protected LocalActorRef(ActorSystem system, Props props, MessageDispatcher dispatcher, Func <Mailbox> createMailbox, InternalActorRef supervisor, ActorPath path, Func <LocalActorRef, ActorCell> createActorCell) //TODO: switch from Func<Mailbox> createMailbox to MailboxType mailboxType { _system = system; _props = props; _dispatcher = dispatcher; _createMailbox = createMailbox; _supervisor = supervisor; _path = path; _cell = createActorCell(this); }
public FutureActorRef(TaskCompletionSource <object> result, Action unregister, ActorPath path) { if (ActorCell.Current != null) { _actorAwaitingResultSender = ActorCell.Current.Sender; } _result = result; _unregister = unregister; _path = path; }
/// <summary> /// Unregisters the temporary actor. /// </summary> /// <param name="path">The path.</param> public void UnregisterTempActor(ActorPath path) { TempContainer.RemoveChild(path.Name); }