Exemple #1
0
 public static IRpcClientBuilder UserNettyClient <TMessage>(this IRpcClientBuilder builder) where TMessage : InvokeMessage
 {
     builder.ConfigureServices((services) =>
     {
         services.AddSingleton <IClientBootstrap <TMessage>, NettyClientBootstrap <TMessage> >();
     });
     return(builder);
 }
Exemple #2
0
 public static IRpcClientBuilder AddCore <TMessage>(this IRpcClientBuilder builder) where TMessage : InvokeMessage
 {
     builder.ConfigureServices((services) =>
     {
         services.AddSingleton <ITransportFactory <TMessage>, DefaultTransportFactory <TMessage> >()
         .AddSingleton <IMessageHandler <TMessage> >(new ClientMessageHandler <TMessage>())
         .AddSingleton <IRpcClient <TMessage>, DefaultRpcClient <TMessage> >();
     });
     return(builder);
 }
Exemple #3
0
        private static IRpcClientBuilder UseDefaultSendRpcRequestStrategy(
            this IRpcClientBuilder builder)
        {
            builder
            .Builder
            .UseDefaultSendRpcRequestStrategy
            (
                builder.ApiUrl,
                builder.ConnectionTimeout,
                builder.EnableTelemetry
            );

            return(builder);
        }
Exemple #4
0
        public static IRpcClientBuilder AddDefaultEthApi(
            this IRpcClientBuilder builder)
        {
            builder
            .UseDefaultSendRpcRequestStrategy();

            builder
            .Builder
            .RegisterType <DefaultEthApiClient>()
            .As <IEthApiClient>()
            .SingleInstance()
            .IfNotRegistered(typeof(IEthApiClient));

            return(builder);
        }
Exemple #5
0
 public static IRpcClientBuilder UseServer(this IRpcClientBuilder builder, string remoteAddress)
 {
     Preconditions.CheckArgument(!string.IsNullOrEmpty(remoteAddress), "服务器地址不能为空");
     builder.UseSetting("DefaultServerAddress", remoteAddress);
     return(builder);
 }