surging 将推出社区版微服务平台
前言
对于.NET大家并不陌生,有大批的企业选择.NET作为公司构建多种应用的开发平台,但是近几年随着微服务,大数据,移动端,物联网兴起,而后.NET社区生态没有跟上时代的步伐,已开始趋于没落,而其中最具代表的微服务,能够提供多种业务场景的解决方案的只有surging ,而surging 最近几年也在不断推动发展,预计明年将升级成为微服务平台,在这之前会在公司的重点项目中使用surging ,以便推出给大家带来稳定,高效的微服务平台,大家如果要得到最新的消息可以添加群:744677125,此群请不要涉及政治,暴力,因为有些人玩不起。多聊技术,积极向上开心的事情,以下是介绍最新的微服务平台功能
过滤器
框架中有AuthorizationFilter,ExceptionFilter,ActionFilter,而ActionFilter是最近新添加的功能,此功能可以用来做权限,创建ActionFilter过滤器如下:
public class PermissionAttribute : BaseActionFilterAttribute { private readonly ISerializer<string> _serializer; public PermissionAttribute() { _serializer = ServiceLocator.Current.Resolve<ISerializer<string>>(); } public override Task OnActionExecutingAsync(ServiceRouteContext actionExecutedContext, CancellationToken cancellationToken) { var payload= RpcContext.GetContext().GetAttachment("payload"); var model= _serializer.Deserialize(payload.ToString().Trim('"').Replace("\\",""),typeof(UserModel)); // actionExecutedContext.ResultMessage.ExceptionMessage = "权限不足";//通过ExceptionMessage 来控制过滤 return Task.FromResult(model); } }
添加注入到引擎中,添加模块配置:
public class IntercepteModule : SystemModule { public override void Initialize(AppModuleContext context) { base.Initialize(context); } /// <summary> /// Inject dependent third-party components /// </summary> /// <param name="builder"></param> protected override void RegisterBuilder(ContainerBuilderWrapper builder) { base.RegisterBuilder(builder); builder.AddClientIntercepted(typeof(CacheProviderInterceptor)); builder.AddFilter(typeof(PermissionAttribute)); //builder.AddClientIntercepted(typeof(LogProviderInterceptor)); } }
然后可以在接口方法中添加Permission特性
[Authorization(AuthType = AuthorizationType.JWT)] [Permission] [HttpPost(true),HttpPut(true)] Task<IdentityUser> Save(IdentityUser requestData);
也可以在接口上添加Permission特性
1 2 3 4 5 6 7 8 9 10 11 12 | [ServiceBundle( "api/{Service}/{Method}" )] [Permission] //[ServiceBundle("api/{Service}")] //[ServiceBundle("api/{Service}/{Method}/test")] //[ServiceBundle("api/{Service}/{Method}/test",false)] public interface IUserService: IServiceKey { [Authorization(AuthType = AuthorizationType.JWT)] [Permission] [HttpPost( true ),HttpPut( true )] Task<IdentityUser> Save(IdentityUser requestData); } |
不登陆调用会看到如下错误信息:
然后从RpcContext.GetContext().GetAttachment("payload")代码中的jwt token 的payload 可以获取信息,断点测试如下:
链路跟踪
链路跟踪采用的是skywalking 6.0 , 而最新的已经升级到8.0, 可以看surging支持的skywalking 8.0:
平台可视化界面
总结
surging 支持的国标28181,rtmp,httpflv,ws,mqtt,rtsp就不过多介绍了,后续surging微服务平台 会更新到https://github.com/microsurging,请大家关注
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
2019-10-20 surging 微服务引擎 -协议主机的Behavior特性