• 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.Resolvestring>>();
            }
            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);
            }
    
            /// 
            /// Inject dependent third-party components
            /// 
            /// 
            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 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 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,请大家关注

  • 相关阅读:
    数据结构系列学习(九) - 循环队列(Circular_Queue)
    webshell免杀之传参方式
    qdox获取java类文件中方法体代码
    [附源码]Java计算机毕业设计SSM电影院订票系统
    Docker基本管理
    计算机毕业设计ssm汽车资讯网站wlri7系统+程序+源码+lw+远程部署
    googletest简介
    在MyBatis中,可以使用动态SQL语句来实现对数据的上移、下移和置顶操作
    [尚硅谷React笔记]——第1章 React简介
    torch(七)、Math operations(1)
  • 原文地址:https://www.cnblogs.com/fanliang11/p/16808852.html