Beispiel #1
0
 /// <summary>
 /// 调用
 /// </summary>
 internal void Call()
 {
     if (!CheckCall())
     {
         return;
     }
     // 1 安全检查
     if (!SecurityCheck())
     {
         return;
     }
     // 2 初始化路由信息
     if (!InitializeContext())
     {
         return;
     }
     // 3 缓存快速处理
     if (RouteChahe.LoadCache(Data.Uri, Data.Bearer, out Data.CacheSetting, out Data.CacheKey, ref Data.ResultMessage))
     {
         //找到并返回缓存
         Data.Status = RouteStatus.Cache;
         return;
     }
     // 4 远程调用
     Data.ResultMessage = Data.RouteHost.ByZero ? CallZero() : CallHttp();
     // 5 结果检查
     Data.IsSucceed = CheckResult(Data);
 }
Beispiel #2
0
        /// <summary>
        ///     调用
        /// </summary>
        internal async void Call()
        {
            if (!CheckCall())
            {
                return;
            }
            if (Data.HostName.Equals("Zero", StringComparison.OrdinalIgnoreCase))
            {
                var manager = new ZeroManager();
                manager.Command(Data);
                return;
            }

            // 1 初始化路由信息
            if (!FindHost() || Data.RouteHost.Failed)
            {
                Data.Status        = RouteStatus.FormalError;
                Data.ResultMessage = ApiResult.NoFindJson;
                return;
            }

            // 2 安全检查
            if (!SecurityCheck())
            {
                return;
            }
            // 3 缓存快速处理
            if (RouteChahe.LoadCache(Data.Uri, Data.Bearer, out Data.CacheSetting, out Data.CacheKey,
                                     ref Data.ResultMessage))
            {
                //找到并返回缓存
                Data.Status = RouteStatus.Cache;
                return;
            }

            // 4 远程调用
            if (!Data.RouteHost.ByZero)
            {
                Data.ResultMessage = await CallHttp();
            }
            else if (ZeroApplication.ZerCenterIsRun)
            {
                Data.ResultMessage = CallZero();
            }
            else
            {
                Data.Status        = RouteStatus.LocalError;
                Data.ResultMessage = ApiResult.NoReadyJson;
                return;
            }
            // 5 结果检查
            if (!CheckResult(Data))
            {
                Data.Status = RouteStatus.RemoteError;
            }
        }