Exemple #1
0
        public void DefaultQuietPeriodSecondsShouldBe1()
        {
            var config = new RpcConfiguration();

            Assert.Equal(1, config.QuietPeriodSeconds);
            Assert.Equal(TimeSpan.FromSeconds(1), config.QuietPeriodTimeSpan);
        }
Exemple #2
0
        public void DefaultShutdownTimeoutSecondsShouldBe3()
        {
            var config = new RpcConfiguration();

            Assert.Equal(3, config.ShutdownTimeoutSeconds);
            Assert.Equal(TimeSpan.FromSeconds(3), config.ShutdownTimeoutTimeSpan);
        }
        public RpcClientFactoryTest()
        {
            var rpcClient = new Mock <IRpcClient>();

            rpcClient.SetupGet(i => i.Protocol).Returns(RpcProtocol.Tcp);
            var clients = new IRpcClient[] { rpcClient.Object };
            var config  = new RpcConfiguration()
            {
                ClientConfig = new Dictionary <string, ClientConfiguration>()
                {
                    { "NoUdp", new ClientConfiguration()
                      {
                          Protocol = RpcProtocol.Udp
                      } },
                    { "Tcp", new ClientConfiguration()
                      {
                          Protocol = RpcProtocol.Tcp, Host = "127.0.0.1", Port = 3333, Timeout = 30
                      } }
                }
            };
            var calback = new Mock <IClientCallBack>();

            calback.Setup(i => i.NewCallBackTask(0, 30, "Tcp", "ReturnParametersNull"))
            .ReturnsAsync(new Response()
            {
                RequestId        = 2,
                Timeout          = 2,
                ReturnParameters = null
            });
            sut = new RpcClientFactory(clients, config, calback.Object);
        }
Exemple #4
0
 public LibuvTcpServerHost(IServiceProvider provider, RpcConfiguration configuration,
                           ILogger <LibuvTcpServerHost> logger, IDecoder <IByteBuffer> decoder, IEncoder <IByteBuffer> encoder,
                           DotNettyServerHandler handler)
 {
     Provider           = provider;
     this.configuration = configuration;
     this.logger        = logger;
     this.decoder       = decoder;
     this.encoder       = encoder;
     this.handler       = handler;
 }
        // Token: 0x0600000D RID: 13 RVA: 0x0000264C File Offset: 0x0000084C
        private static void ConfigureRpc()
        {
            string   directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string   path          = Path.Combine(directoryName, MonitoringService.workerProcessName);
            Assembly assembly      = Assembly.LoadFile(path);
            Type     type          = assembly.GetType(MonitoringService.rpcConfigurationType);

            if (type == null)
            {
                string message = string.Format("Unable to load class {0}. Reason: Assembly.GetType() returned null when getting the class type.", MonitoringService.rpcConfigurationType);
                throw new InvalidOperationException(message);
            }
            RpcConfiguration rpcConfiguration = (RpcConfiguration)Activator.CreateInstance(type, new object[0]);

            rpcConfiguration.Initialize();
        }
Exemple #6
0
 public LibuvTcpClient(RpcConfiguration configuration, IDecoder <IByteBuffer> decoder, IEncoder <IByteBuffer> encoder, IClientCallBack callBack)
 {
     this.encoder = encoder;
     bootstrap
     .Group(group)
     .Channel <TcpSocketChannel>()
     .Option(ChannelOption.TcpNodelay, true)
     .Handler(new ActionChannelInitializer <IChannel>(channel =>
     {
         var lengthFieldLength = configuration.LengthFieldLength;
         channel.Pipeline.AddLast(new LengthFieldBasedFrameDecoder(ByteOrder.BigEndian,
                                                                   configuration.MaxFrameLength, 0, lengthFieldLength, 0, lengthFieldLength, true));
         channel.Pipeline.AddLast(new ResponseDecoder(decoder), new LengthFieldPrepender(lengthFieldLength),
                                  new DotNettyClientHandler(callBack));
     }));
 }
Exemple #7
0
 internal RpcUdpConnection(UdpPeer parent, IRpcPeer rpcPeer, RpcConfiguration configuration) : base(parent)
 {
     if (parent == null)
     {
         throw new ArgumentNullException(nameof(parent));
     }
     if (rpcPeer == null)
     {
         throw new ArgumentNullException(nameof(rpcPeer));
     }
     if (configuration == null)
     {
         throw new ArgumentNullException(nameof(configuration));
     }
     this.configuration = configuration;
     this.rpcPeer       = rpcPeer;
 }
Exemple #8
0
 public UdpClient(IServiceProvider provider, RpcConfiguration configuration, IDecoder <IByteBuffer> decoder,
                  IEncoder <IByteBuffer> encoder, IClientCallBack callBack)
 {
     this.encoder = encoder;
     bootstrap
     .Group(group)
     .Channel <SocketDatagramChannel>()
     .LocalAddress(configuration.UdpLocalPort)
     .Option(ChannelOption.SoBroadcast, true)
     .Handler(new ActionChannelInitializer <IChannel>(channel =>
     {
         var lengthFieldLength = configuration.LengthFieldLength;
         channel.Pipeline.AddLast(new UdpClientHandler(provider.GetRequiredService <ILogger <UdpClientHandler> >()));
         channel.Pipeline.AddLast(new LengthFieldBasedFrameDecoder(ByteOrder.BigEndian,
                                                                   configuration.MaxFrameLength, 0, lengthFieldLength, 0, lengthFieldLength, true));
         channel.Pipeline.AddLast(new ResponseDecoder(decoder), new DatagramPacketEncoder <IByteBuffer>(new UdpLengthFieldPrepender(lengthFieldLength)),
                                  new DotNettyClientHandler(callBack));
     }));
 }
Exemple #9
0
        public void DefaultPortShouldBe8989()
        {
            var result = new RpcConfiguration().Port;

            Assert.Equal(8989, result);
        }
Exemple #10
0
        public void DefaultLengthFieldLengthShouldBe4()
        {
            var config = new RpcConfiguration();

            Assert.Equal(4, config.LengthFieldLength);
        }
Exemple #11
0
        public void DefaultMaxFrameLengthShouldBe5242880()
        {
            var config = new RpcConfiguration();

            Assert.Equal(5 * 1024 * 1024, config.MaxFrameLength);
        }
Exemple #12
0
        public void DefaultSoBacklogShouldBe8192()
        {
            var config = new RpcConfiguration();

            Assert.Equal(8192, config.SoBacklog);
        }
 internal RpcTcpConnectionEncrypted(TcpPeer parent, IRpcPeer rpcPeer, RpcConfiguration configuration) : base(
         parent, rpcPeer, configuration)
 {
 }
Exemple #14
0
 public RpcClientFactory(IEnumerable <IRpcClient> rpcClients, RpcConfiguration configuration, IClientCallBack callBack)
 {
     this.configuration = configuration;
     this.callBack      = callBack;
     clients            = rpcClients.ToDictionary(i => i.Protocol);
 }
 internal RpcUdpConnectionEncrypted(UdpPeer parent, ICipher cipher, IRpcPeer rpcPeer, RpcConfiguration configuration) : base(parent, rpcPeer, configuration)
 {
     if (cipher == null)
     {
         throw new ArgumentNullException(nameof(cipher));
     }
     this.cipher = cipher;
     this.dh     = new DiffieHellmanImpl(cipher);
 }