Exemple #1
0
        public TRes Sync(TReq request, RpcTimeouts timeouts = null)
        {
            AssertBound();
            if (!Async)
            {
                AssertThreading();
            }

            var task = StartInternal(Lifetime.Eternal, request, SynchronousScheduler.Instance);

            var stopwatch = new Stopwatch();

            stopwatch.Start();

            var timeoutsToUse = RpcTimeouts.GetRpcTimeouts(timeouts);

            if (!task.Wait(timeoutsToUse.ErrorAwaitTime))
            {
                throw new TimeoutException($"Sync execution of rpc `{Location}` is timed out in {timeoutsToUse.ErrorAwaitTime.TotalMilliseconds} ms");
            }

            stopwatch.Stop();

            var freezeTime = stopwatch.ElapsedMilliseconds;

            if (freezeTime > timeoutsToUse.WarnAwaitTime.TotalMilliseconds)
            {
                Log.Root.Error("Sync execution of rpc `{0}` executed too long: {1} ms", Location, freezeTime);
            }

            return(task.Result.Value.Unwrap());
        }
Exemple #2
0
        public static RpcTimeouts GetRpcTimeouts([CanBeNull] RpcTimeouts timeouts)
        {
            RpcTimeouts timeoutsToUse;

            if (RespectRpcTimeouts)
            {
                timeoutsToUse = timeouts ?? Default;
            }
            else
            {
                timeoutsToUse = timeouts == null
          ? Maximal
          : Max(timeouts, Maximal);
            }
            return(timeoutsToUse);
        }
Exemple #3
0
 public static RpcTimeouts Max(RpcTimeouts x, RpcTimeouts y)
 {
     return(new RpcTimeouts(
                x.WarnAwaitTime > y.WarnAwaitTime ? x.WarnAwaitTime : y.WarnAwaitTime,
                x.ErrorAwaitTime > y.ErrorAwaitTime ? x.ErrorAwaitTime : y.ErrorAwaitTime));
 }
Exemple #4
0
 public TRes Sync(TReq request, RpcTimeouts timeouts = null)
 {
     Assertion.AssertNotNull(myHandler, "myHandler != null");
     return(myHandler(myBindLifetime, request).Result.Value.Unwrap());
 }