/// <summary> /// メソッド呼び出し情報を指定してインスタンスを生成します。 /// </summary> /// <param name="message">メッセージ</param> /// <param name="innerException">内部例外</param> /// <param name="method">メソッド</param> /// <param name="host">ホスト</param> /// <param name="options">オプション</param> /// <param name="interceptor">失敗した割込処理</param> public GrpcClientMethodException(string message, Exception innerException, IMethod method, string host, CallOptions options, IGrpcInterceptor interceptor) : base(message, innerException) { m_Method = method; m_Host = host; m_Options = options; m_Interceptor = interceptor; }
/// <summary> /// サーバー側で割込処理が行われたときの処理を行います。 /// </summary> /// <param name="context">コンテキスト</param> /// <param name="interceptor">割込処理</param> /// <param name="elapsedMilliseconds">処理時間(ミリ秒)</param> public void NotifyMethodIntercepted(ServerCallContext context, IGrpcInterceptor interceptor, double elapsedMilliseconds) { try { NotifyServerIntercept h = MethodIntercepted; if (h != null) { h(context, interceptor, elapsedMilliseconds); } } catch { } }
/// <summary> /// 指定された割込処理の大小比較を行います。 /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> private static int CompareInterceptor(IGrpcInterceptor a, IGrpcInterceptor b) { if (a != null && b != null) { return(a.Priority.CompareTo(b.Priority)); } else if (a != null) { return(1); } else if (b != null) { return(-1); } else { return(0); } }
/// <summary> /// クライアント側で割込処理が行われたときの処理を行います。 /// </summary> /// <param name="method">メソッド</param> /// <param name="host">ホスト</param> /// <param name="options">オプション</param> /// <param name="interceptor">割込処理</param> /// <param name="elapsedMilliseconds">処理時間(ミリ秒)</param> public void NotifyMethodIntercepted(IMethod method, string host, CallOptions options, IGrpcInterceptor interceptor, double elapsedMilliseconds) { try { NotifyClientIntercept h = MethodIntercepted; if (h != null) { h(method.ServiceName, method.Name, host, interceptor, elapsedMilliseconds); } } catch { } }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="interceptor"></param> /// <param name="elapsedMilliseconds"></param> private static void PerformanceListener_MethodIntercepted(ServerCallContext context, IGrpcInterceptor interceptor, double elapsedMilliseconds) { string message = string.Format("[{0}]【Intercept】{1} {2} {3:f4}ms", GetCallCounter(context), context.Method, interceptor.Name, elapsedMilliseconds); Console.WriteLine(message); }
/// <summary> /// メソッド呼び出し情報を指定してインスタンスを生成します。 /// </summary> /// <param name="message">メッセージ</param> /// <param name="innerException">内部例外</param> /// <param name="context">コンテキスト</param> /// <param name="interceptor">失敗した割込処理</param> public GrpcServerMethodException(string message, Exception innerException, ServerCallContext context, IGrpcInterceptor interceptor) : base(message, innerException) { m_Context = context; m_Interceptor = interceptor; }
/// <summary> /// /// </summary> /// <param name="serviceName"></param> /// <param name="methodName"></param> /// <param name="host"></param> /// <param name="interceptor"></param> /// <param name="elapsedMilliseconds"></param> private void PerformanceListener_MethodIntercepted(string serviceName, string methodName, string host, IGrpcInterceptor interceptor, double elapsedMilliseconds) { string message = string.Format("【Intercept】{0} {1} {2} {3} {4:f4}ms", host, serviceName, methodName, interceptor.Name, elapsedMilliseconds); AppendLog(message); }