예제 #1
0
 public Task LogAsync <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter)
 {
     return(_loggingActors.Ask(new LogItemBuilder()
                               .SetLogLevel(logLevel)
                               .SetEventId(eventId)
                               .SetState(state)
                               .SetException(exception)
                               .SetFormatter((o, ex) => formatter?.Invoke((TState)o, ex))
                               .Build()));
 }
예제 #2
0
        public static TAnswer AskAndWait <TAnswer>(this ICanTell self, object message, TimeSpan timeout)
        {
            var task = self.Ask <TAnswer>(message, timeout);

            task.Wait();
            return(task.Result);
        }
        //when asking from outside of an actor, we need to pass a system, so the FutureActor can register itself there and be resolvable for local and remote calls
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="self">TBD</param>
        /// <param name="message">TBD</param>
        /// <param name="timeout">TBD</param>
        /// <returns>TBD</returns>
        public static async Task <object> AskObservable <TMessage>(this ICanTell self, TMessage message) where TMessage : notnull
        {
            var activity = Activity.Current;
            var res      = await self.Ask <ObservableEnvelope>(new ObservableEnvelope <TMessage>(message, activity.Context));

            return(res.Body);
        }
예제 #4
0
        private void LogResultPickedUp(RunnableScriptObject message, ICanTell statusUpdateActor)
        {
            Task t = statusUpdateActor.Ask(new UpdateRunStatusAsPickedUpRequestMessage
            {
                ScriptId = message.RunnableScriptId
            });

            t.Wait();
        }
예제 #5
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <typeparam name="T">TBD</typeparam>
 /// <param name="self">TBD</param>
 /// <param name="message">TBD</param>
 /// <param name="cancellationToken">TBD</param>
 /// <returns>TBD</returns>
 public static Task <T> Ask <T>(this ICanTell self, object message, CancellationToken cancellationToken)
 {
     return(self.Ask <T>(message, null, cancellationToken));
 }
예제 #6
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <typeparam name="T">TBD</typeparam>
 /// <param name="self">TBD</param>
 /// <param name="message">TBD</param>
 /// <param name="timeout">TBD</param>
 /// <returns>TBD</returns>
 public static Task <T> Ask <T>(this ICanTell self, object message, TimeSpan?timeout = null)
 {
     return(self.Ask <T>(message, timeout, CancellationToken.None));
 }
예제 #7
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="self">TBD</param>
 /// <param name="message">TBD</param>
 /// <param name="timeout">TBD</param>
 /// <param name="cancellationToken">TBD</param>
 /// <returns>TBD</returns>
 public static Task <object> Ask(this ICanTell self, object message, TimeSpan?timeout, CancellationToken cancellationToken)
 {
     return(self.Ask <object>(message, timeout, cancellationToken));
 }
예제 #8
0
파일: Futures.cs 프로젝트: vonwenm/akka.net
 //when asking from outside of an actor, we need to pass a system, so the FutureActor can register itself there and be resolvable for local and remote calls
 public static Task <object> Ask(this ICanTell self, object message, TimeSpan?timeout = null)
 {
     return(self.Ask <object>(message, timeout));
 }
예제 #9
0
        protected async Task <ICanTell> GetActor <T>() where T : ActorBase
        {
            var result = await _addressBook.Ask <AddressBook.Found>(new AddressBook.Get(typeof(T)));

            return(result.Ref);
        }