예제 #1
0
        private async Task <object> Exec(string serviceName, string route, object[] args, Dictionary <string, string> meta, Type returnValueType)
        {
            ServiceNodeInfo node;

            if (UraganoSettings.IsDevelopment)
            {
                node = new ServiceNodeInfo {
                    Address = UraganoSettings.ServerSettings.IP.ToString(), Port = UraganoSettings.ServerSettings.Port
                }
            }
            ;
            else
            {
                node = await LoadBalancing.GetNextNode(serviceName);
            }
            var client = await ClientFactory.CreateClientAsync(node.Address, node.Port);

            var result = await client.SendAsync(new InvokeMessage(route, args, meta));

            if (result.Status != RemotingStatus.Ok)
            {
                throw new RemoteInvokeException(route, result.Result?.ToString(), result.Status);
            }
            if (returnValueType == null)
            {
                return(null);
            }
            return(result.Result);
        }
예제 #2
0
        private async Task <IServiceResult> Exec(string serviceName, string route, object[] args, Dictionary <string, string> meta)
        {
            var node = await LoadBalancing.GetNextNode(serviceName, route, args, meta);

            var client = await ClientFactory.CreateClientAsync(serviceName, node);

            var result = await client.SendAsync(new InvokeMessage(route, args, meta));

            if (result.Status != RemotingStatus.Ok)
            {
                throw new RemoteInvokeException(route, result.Result?.ToString(), result.Status);
            }
            return(result);
        }