• 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,请大家关注

  • 相关阅读:
    想当设备管理师?满足这三个报考条件就可以
    ABB电磁流量计维修信号变送器维修41F/E4技术参数
    .babyk勒索病毒解析:恶意更新如何威胁您的数据安全
    XSS 从 PDF 中窃取数据
    [Codeforces] number theory (R1200) Part.9
    GB28181安防视频融合汇聚平台EasyCVR如何实现视频画面自定义标签?
    dart 学习 之 字符串插值,空变量 null,避空运算符,条件属性访问,集合字面量,箭头语法
    (Matlab)基于网格搜素优化的支持向量机实现电力负荷预测
    软件测试的方法详细介绍
    气相色谱质谱仪样品传输装置中电动针阀和微泄漏阀的解决方案
  • 原文地址:https://www.cnblogs.com/fanliang11/p/16808852.html