fanliang11 / surging

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
MIT License
3.24k stars 924 forks source link

组件化缓存拦截器和拦截器设计 #326

Open fanliang11 opened 5 years ago

fanliang11 commented 5 years ago

针对于引擎中的缓存拦截可以设计成组件方式,当服务提供者未提供接口引用,那么可以不加载CacheIntercepteModule 模块,这样就不会设置缓存拦截

    public class CacheIntercepteModule : 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));

        }
    }

也可以针对于引擎中的拦截设计成组件方式,拦截是不需要依赖于接口,所以服务提供者未提供接口引用,也不会出现问题,也可以不加载IntercepteModule 模块,这样就不会设置拦截

    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(LogProviderInterceptor));
        }
    }