Git Product home page Git Product logo

fanliang11 / surging Goto Github PK

View Code? Open in Web Editor NEW
3.2K 305.0 924.0 27.84 MB

Surging is a micro-service engine that provides a lightweight, high-performance, modular RPC request pipeline. support Event-based Asynchronous Pattern and reactive programming ,The service engine supports http, TCP, WS,Grpc, Thrift,Mqtt, UDP, and DNS protocols. It uses ZooKeeper and Consul as a registry, and integrates it. Hash, random, polling, Fair Polling as a load balancing algorithm, built-in service governance to ensure reliable RPC communication, the engine contains Diagnostic, link tracking for protocol and middleware calls, and integration SkyWalking Distributed APM

License: MIT License

C# 88.57% CSS 1.18% JavaScript 3.84% Smarty 0.25% PowerShell 0.01% HTML 1.93% Thrift 0.01% Less 4.21%
microservices apigateway surging rabbitmq messagepack protobuffer json-serialization consul zookeeper log4net

surging's Issues

网关聚合模型传递

{
“ServiceAggregation”:[
{
           "RoutePath": "api/user/getuser",
           "ServiceKey": "User",
          "Params":{"UserId":1},
           "Key":"Users"
},
{
           "RoutePath": "api/user/getuser",
           "ServiceKey": "User",
          "Params":{"UserId":1},
           "Key":"Roles"
}]
}

result return:

{"User":{"UserId": 1,"Name":"Fanly","Age":18},"Roles":{"RoleName": "Admin"}}

服务间通过远程代理调用异常,请帮忙给看一下?

qq 20180106133010
我用这种方式远程调用接口,同时已经将远程接口引用到项目中

this.GetService<IProductService>().GetProduct(1);

远程服务接口声明

[Service(Date ="20180106",Director ="",Name ="获取产品数据")]
  Task<string> GetProduct(int id);

请帮忙分析一下原因,看看我的用法有问题吗,顺便能给出一个服务间调用的实例demo么,这个比较急,谢谢了!

独立部署成功,热部署无效

@fanliang11 我独立创建领域及控制台执行,并启动服务完成了服务的注册,对接口进行调用也OK;98端口为源项目服务,99是我自己实现的一个demo;现想把自己实现的服务寄宿在98端口对应的服务上,一直没有成功;我进行两种尝试
1.98服务启动后 将领域dll直接扔到服务目录一直无法发现服务;
2.98端口服务停掉,先放自现实的dll再启动,会报异常,无法加载所给的dll;

运行环境net core sdk要求

运行Surging.Services.Server项目,出现闪退现象。如下图

image

image

解决:发现net core sdk 是2.0的不满足要求,需要升级为最新版本,如下图
image

Surging.ApiGateway 启动报错

InvalidOperationException: Can not find compilation library location for package 'Microsoft.ApplicationInsights'
Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths()
System.Linq.Enumerable+SelectManySingleSelectorIterator.MoveNext()
Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeatureProvider.PopulateFeature(IEnumerable<ApplicationPart> parts, MetadataReferenceFeature feature)
Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature<TFeature>(TFeature feature)
Microsoft.AspNetCore.Mvc.Razor.Internal.RazorReferenceManager.GetCompilationReferences()
System.Threading.LazyInitializer.EnsureInitializedCore<T>(ref T target, ref bool initialized, ref object syncLock, Func<T> valueFactory)
Microsoft.AspNetCore.Mvc.Razor.Internal.RazorReferenceManager.get_CompilationReferences()
Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRoslynCompilationService.CreateCompilation(string compilationContent, string assemblyName)
Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRoslynCompilationService.Compile(RelativeFileInfo fileInfo, string compilationContent)
Microsoft.AspNetCore.Mvc.Razor.Internal.RazorCompilationService.Compile(RelativeFileInfo file)
Microsoft.AspNetCore.Mvc.Razor.Internal.CompilerCache.CreateCacheEntry(string relativePath, string normalizedPath, Func<RelativeFileInfo, CompilationResult> compile)
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Razor.Internal.CompilerCache.GetOrAdd(string relativePath, Func<RelativeFileInfo, CompilationResult> compile)
Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorPageFactoryProvider.CreateFactory(string relativePath)
Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.CreateCacheResult(HashSet<IChangeToken> expirationTokens, string relativePath, bool isMainPage)
Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.OnCacheMiss(ViewLocationExpanderContext expanderContext, ViewLocationCacheKey cacheKey)
Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.LocatePageFromViewLocations(ActionContext actionContext, string pageName, bool isMainPage)
Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.FindView(ActionContext context, string viewName, bool isMainPage)
Microsoft.AspNetCore.Mvc.ViewEngines.CompositeViewEngine.FindView(ActionContext context, string viewName, bool isMainPage)
Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor.FindView(ActionContext actionContext, ViewResult viewResult)
Microsoft.AspNetCore.Mvc.ViewResult+<ExecuteResultAsync>d__26.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+<InvokeResultAsync>d__30.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+<InvokeNextResultFilterAsync>d__28.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ResultExecutedContext context)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+<InvokeNextResourceFilter>d__22.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ResourceExecutedContext context)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+<InvokeAsync>d__20.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Builder.RouterMiddleware+<Invoke>d__4.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware+<Invoke>d__7.MoveNext()

运行案例出现异常

Unhandled Exception: System.AggregateException: One or more errors occurred. (Value cannot be null.
Parameter name: serviceKey) ---> System.ArgumentNullException: Value cannot be null.
Parameter name: serviceKey
at Autofac.Core.KeyedService..ctor(Object serviceKey, Type serviceType)
at Autofac.ResolutionExtensions.IsRegisteredWithKey[TService](IComponentContext context, Object serviceKey)
at Surging.Core.CPlatform.CPlatformContainer.IsRegistered[T](Object serviceKey) in C:\proj\surging\src\Surging.Core\Surging.Core.CPlatform\CPlatformContainer.cs:line 25
at Surging.Core.ProxyGenerator.Implementation.ServiceProxyBase.d__81.MoveNext() in C:\proj\surging\src\Surging.Core\Surging.Core.ProxyGenerator\Implementation\ServiceProxyBase.cs:line 67 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
at Surging.Cores.ClientProxys.UserServiceClientProxy.d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Surging.Services.Client.Startup.<>c__DisplayClass7_0.<b__0>d.MoveNext() in C:\proj\surging\src\Surging.Services\Surging.Services.Client\Startup.cs:line 83
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at Surging.Services.Client.Startup.Test(IServiceProxyFactory serviceProxyFactory) in C:\proj\surging\src\Surging.Services\Surging.Services.Client\Startup.cs:line 75
at Surging.Services.Client.Program.Main(String[] args) in C:\proj\surging\src\Surging.Services\Surging.Services.Client\Program.cs:line 74

服务之间调用的时候,会报错。

    public Task<string> GetUserName(int id)
    {
        Console.WriteLine("被调用");

        StartRequest1();

        return Task.FromResult($"id:{id} is name fanly.");
    }


    private static void StartRequest1()
    {

        var service = ServiceLocator.GetService<IServiceProxyFactory>();
        var userProxy = service.CreateProxy<IUser2Service>();
        var ss = userProxy.GetUserName(123);
        Console.WriteLine(ss);

    }

2018-01-04 13:25:09,225 [32] ERROR Surging.Core.CPlatform.Runtime.Server.Implementation.DefaultServiceExecutor [(null)] - 执行本地逻辑时候发生了错误。
Autofac.Core.Registration.ComponentNotRegisteredException: The requested service 'Surging.Core.ProxyGenerator.IServiceProxyFactory' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.
at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable1 parameters) at Autofac.ResolutionExtensions.Resolve[TService](IComponentContext context, IEnumerable1 parameters)
at Surging.Core.CPlatform.Utilities.ServiceLocator.GetServiceT in D:\Users\yxl2016\Desktop\surging-master\src\Surging.Core\Surging.Core.CPlatform\Utilities\ServiceLocator.cs:line 12
at Surging.Modules.Common.Domain.UserService.StartRequest1() in D:\Users\yxl2016\Desktop\surging-master\src\Surging.Modules\Surging.Modules.Common\Domain\UserService.cs:line 32
at Surging.Modules.Common.Domain.UserService.GetUserName(Int32 id) in D:\Users\yxl2016\Desktop\surging-master\src\Surging.Modules\Surging.Modules.Common\Domain\UserService.cs:line 23
at (Object , Object[] )
at Surging.Core.CPlatform.Runtime.Server.Implementation.ServiceDiscovery.Implementation.ClrServiceEntryFactory.<>c__DisplayClass5_0.b__1(String key, IDictionary`2 parameters)
at Surging.Core.CPlatform.Runtime.Server.Implementation.DefaultServiceExecutor.d__6.MoveNext()

前几天下载的代码怎么运行报错

您好,前几天下载下来学习,想在本地运行一下,出现 由于目标计算机积极拒绝,无法连接
本地开发环境的是是vs2017 ,求指导

如何使用surging快速搭建项目

  1. 运行网关程序

default
可以把红框的(服务 | | 领域接口)删除,只部署运行的网关
default

  1. 新建服务项目

2.1 需要引用的服务创建

default

default
default

default

2.2 无需引用的服务创建

qq 20180116163838

default

default

default

default

default

这里只是个人的简单理解和使用,继续研究和使用作者代码,感谢作者的支持

在调动接口http://localhost:729/api/user/getuser报错

我讲demo中的接口

    [Command(Strategy = StrategyType.Injection, Injection = @"return

new Surging.IModuleServices.Common.Models.UserModel
{
Name=""fanly"",
Age=19
};", InjectionNamespaces = new string[] { "Surging.IModuleServices.Common" }, RequestCacheEnabled = true)]
[Service(Date = "2017-8-11", Director = "fanly", Name = "获取用户")]
[InterceptMethod(CachingMethod.Get, Key = "GetUser_id_0", CacheSectionType = SectionType.ddlCache, Mode = CacheTargetType.Redis, Time = 480)]
Task GetUser(UserModel user);

属性RequestCacheEnabled 修改为true 想进入InterceptMethod 查看操作缓存的过程,结果报错,麻烦给看看是怎么回事,配置哪里有问题么?

===================================================

NullReferenceException: Object reference not set to an instance of an object.
Surging.Core.ProxyGenerator.Interceptors.Implementation.InterceptorProvider.GetInvocation(object proxy, IDictionary<string, object> parameters, string serviceId, Type returnType) in InterceptorProvider.cs
+
{
var entry = (from q in _serviceEntryManager.GetEntries()
let k = q.Attributes
where q.Descriptor.Id == serviceId
select q).FirstOrDefault();
var constructor = InvocationMethods.CompositionInvocationConstructor;
return constructor.Invoke(new object[]{
parameters,
serviceId,
GetKey(parameters),
entry.Attributes,
returnType,
proxy
Surging.Core.ProxyGenerator.Implementation.ServiceProxyBase.GetInvocation(IDictionary<string, object> parameters, string serviceId, Type returnType) in ServiceProxyBase.cs
+
}
}

    private IInvocation GetInvocation(IDictionary<string, object> parameters, string serviceId, Type returnType)
    {
        var invocation = _serviceProvider.GetInstances<IInterceptorProvider>();
        return invocation.GetInvocation(this, parameters, serviceId, returnType);
    }
    
    #endregion Protected Method
}

}
Surging.Core.ProxyGenerator.Implementation.ServiceProxyBase+d__8.MoveNext() in ServiceProxyBase.cs
+
var invoker = _serviceProvider.GetInstances(command.Strategy.ToString());
return await invoker.Invoke(parameters, serviceId, _serviceKey, typeof(T) == typeof(Object));
}
}
else
{
var invocation = GetInvocation(parameters, serviceId, typeof(T));
await _interceptor.Intercept(invocation);
message = invocation.ReturnValue is RemoteInvokeResultMessage
? invocation.ReturnValue as RemoteInvokeResultMessage : null;
result = invocation.ReturnValue;
}
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
System.Runtime.CompilerServices.TaskAwaiter.GetResult()
Surging.Core.ProxyGenerator.Implementation.RemoteServiceProxy+d__2.MoveNext() in RemoteServiceProxy.cs
+
{
}
public new async Task Invoke(IDictionary<string, object> parameters, string serviceId)
{
return await base.Invoke(parameters, serviceId);
}
}
}
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
System.Runtime.CompilerServices.TaskAwaiter.GetResult()
Surging.Core.ProxyGenerator.Implementation.ServiceProxyProvider+d__3.MoveNext() in ServiceProxyProvider.cs
+
var proxy= new RemoteServiceProxy(parameters["serviceKey"].ToString(), _serviceProvider);
result = await proxy.Invoke(parameters, serviceRoute.ServiceDescriptor.Id);
}
else
{
var proxy = new RemoteServiceProxy(null, _serviceProvider);
result = await proxy.Invoke(parameters, serviceRoute.ServiceDescriptor.Id);
}
return result;
}
public async Task Invoke(IDictionary<string, object> parameters, string routePath, string serviceKey)
{
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
System.Runtime.CompilerServices.TaskAwaiter.GetResult()
Surging.ApiGateway.Controllers.ServicesController+d__4.MoveNext() in ServicesController.cs
+
result = ServiceResult.Create(true, await _serviceProxyProvider.Invoke(model, path, serviceKey));
result.StatusCode = (int)ServiceStatusCode.Success;
}
else
{
result = ServiceResult.Create(true, await _serviceProxyProvider.Invoke(model, path));
result.StatusCode = (int)ServiceStatusCode.Success;
}
}
}
return result;
}
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
lambda_method(Closure , object )
Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable+Awaiter.GetResult()
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d__12.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d__10.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d__14.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+d__22.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+d__17.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+d__15.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Builder.RouterMiddleware+d__4.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware+d__7.MoveNext()

Show raw exception details
System.NullReferenceException: Object reference not set to an instance of an object.
at Surging.Core.ProxyGenerator.Interceptors.Implementation.InterceptorProvider.GetInvocation(Object proxy, IDictionary2 parameters, String serviceId, Type returnType) in E:\work\TechnicalPointSurvey\surging\surging-master\src\Surging.Core\Surging.Core.ProxyGenerator\Interceptors\Implementation\InterceptorProvider.cs:line 30 at Surging.Core.ProxyGenerator.Implementation.ServiceProxyBase.GetInvocation(IDictionary2 parameters, String serviceId, Type returnType) in E:\work\TechnicalPointSurvey\surging\surging-master\src\Surging.Core\Surging.Core.ProxyGenerator\Implementation\ServiceProxyBase.cs:line 114
at Surging.Core.ProxyGenerator.Implementation.ServiceProxyBase.d__81.MoveNext() in E:\work\TechnicalPointSurvey\surging\surging-master\src\Surging.Core\Surging.Core.ProxyGenerator\Implementation\ServiceProxyBase.cs:line 69 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
at Surging.Core.ProxyGenerator.Implementation.RemoteServiceProxy.d__21.MoveNext() in E:\work\TechnicalPointSurvey\surging\surging-master\src\Surging.Core\Surging.Core.ProxyGenerator\Implementation\RemoteServiceProxy.cs:line 32 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
at Surging.Core.ProxyGenerator.Implementation.ServiceProxyProvider.d__31.MoveNext() in E:\work\TechnicalPointSurvey\surging\surging-master\src\Surging.Core\Surging.Core.ProxyGenerator\Implementation\ServiceProxyProvider.cs:line 31 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
at Surging.ApiGateway.Controllers.ServicesController.d__4.MoveNext() in E:\work\TechnicalPointSurvey\surging\surging-master\src\Surging.ApiGateway\Controllers\ServicesController.cs:line 64
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at lambda_method(Closure , Object )
at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Builder.RouterMiddleware.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.d__7.MoveNext()

Surging 数据返回大小有限制么?

服务端启动成功,2018/1/3 17:36:13。
fail: Surging.Core.DotNetty.DotNettyServerMessageListener[0]
与服务器:[::ffff:127.0.0.1]:34691通信时发送了错误。
System.Net.Sockets.SocketException (0x80004005): 远程主机强迫关闭了一个现有的连
接。
at DotNetty.Transport.Channels.Sockets.SocketChannelAsyncOperation.Validate()

at DotNetty.Transport.Channels.Sockets.AbstractSocketByteChannel.SocketByteCh
annelUnsafe.FinishRead(SocketChannelAsyncOperation operation)
fail: Surging.Core.DotNetty.DotNettyServerMessageListener[0]
与服务器:[::ffff:127.0.0.1]:57473通信时发送了错误。
System.Net.Sockets.SocketException (0x80004005): 远程主机强迫关闭了一个现有的连
接。
at DotNetty.Transport.Channels.Sockets.SocketChannelAsyncOperation.Validate()

at DotNetty.Transport.Channels.Sockets.AbstractSocketByteChannel.SocketByteCh
annelUnsafe.FinishRead(SocketChannelAsyncOperation operation)

api网关调用rpc服务时,如果参数不符,直接返回了Entity:null,机制有问题;

问题描述:
方法定义:public Task GetUserLevelModel(string userid)

此时如果http post的请求中,没有传递参数,目前机制是直接返回结果:{"Entity":null,"IsSucceed":true,"Message":"","StatusCode":200}
resp结果中没有参数不正确的提示;

且:此时用户的代码压根没执行,因此用户程序中参数为空的检查是不执行的。

原因分析:经过断点跟踪,
在 public async Task<ServiceResult> Path(string path, [FromQuery]string serviceKey, [FromBody]Dictionary<string, object> model) 的model参数为null或者参数的key不在model中,在发起rpc调用时TransportClient类 SendAsync方法,会抛异常,api网关直接将返回如上结果。

结论:此处的判断逻辑或者说错误提示应该更加明确,在参数不齐全的情况下,异常后的排查成本会很高。

服务调用

serviceProxyProvider.Invoke(model, path, serviceKey);
我写了一个测试 在service.client
public static void Test(IServiceProxyProvider serviceProxyProvider)
{
Dictionary<string, object> model = new Dictionary<string, object>();
model.Add("UserId", "1");
string path = "api/user/getuser";
string serviceKey = "User";

        var userProxy = serviceProxyProvider.Invoke<object>(model, path, serviceKey);
        var s = userProxy.Result;
    }

想通过api 方式调用服务
服务端和客户端启动后
image
user返回的信息
image
返回的是自定义属性当中的?
image

两个服务之间该怎么调用呢?

var result = this.GetService().GetMembers(10).Result; 用这个调用本服务是可以的,但是如何调用其他服务的接口呢?
例如我有两个服务一个订单服务,一个库存服务,我要在订单的服务中调用库存的服务,订单服务是不是需要引用订单服务中定义的接口库?

客户端 UseProxy与AddClientProxy部分功能重复了

builder.Services.Register(provider =>new ServiceProxyFactory(
                 provider.Resolve<IRemoteInvokeService>(),
                 provider.Resolve<ITypeConvertibleService>(),
                 provider.Resolve<IServiceProvider>(),
                 builder.GetInterfaceService()
                 )).As<IServiceProxyFactory>().SingleInstance();

new ServiceProxyFactory应该与UseProxy的作用重复了

使用api网关遇到的问题

hi~
我在使用api网关时,遇到几点小问题

  1. ModuleName 是不是取Service前的Name;比如UserAppService, ModuleName 是UserApp , 取User 不行

  2. 使用api网关能否指定http Method, GET/ POST ; 貌似现在只能是 POST JSON

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.