示例#1
0
 private TcpMetricsClientWrapper(IOutbountChannel channel,
                                 TimeSpan breathTime,
                                 IFormatter formatter,
                                 Func <Encoding> encodingFactory)
     : base(channel, breathTime, formatter, encodingFactory)
 {
 }
示例#2
0
 internal static TcpMetricsClientWrapper Stub(IOutbountChannel channel        = null,
                                              IFormatter formatter            = null,
                                              Func <Encoding> encodingFactory = null)
 {
     return(new TcpMetricsClientWrapper(channel ?? new Mock <IOutbountChannel>().Object,
                                        TimeSpan.FromMilliseconds(-1d),
                                        formatter ?? new Mock <IFormatter>().Object,
                                        encodingFactory ?? (() => new Mock <Encoding>().Object)));
 }
示例#3
0
 public static Task <IMetricsClient> StartAsync(IOutbountChannel channel,
                                                TimeSpan breathTime,
                                                IFormatter formatter            = null,
                                                Func <Encoding> encodingFactory = null)
 {
     return(channel.ConnectAsync()
            .ContinueWithOrThrow(_ => (IMetricsClient) new TcpMetricsClient(channel,
                                                                            breathTime,
                                                                            formatter ?? new DefaultFormatter(),
                                                                            encodingFactory ?? (() => new UTF8Encoding(true)))));
 }
示例#4
0
        protected TcpMetricsClient(IOutbountChannel channel,
                                   TimeSpan breathTime,
                                   IFormatter formatter,
                                   Func <Encoding> encodingFactory)
        {
            _channel         = channel;
            _breathTime      = breathTime;
            _formatter       = formatter;
            _encodingFactory = encodingFactory;
            _cts             = new CancellationTokenSource();

            BackgroundWorkAsync(_cts.Token);
        }
示例#5
0
 public static Task <IMetricsClient> StartAsync(IOutbountChannel channel,
                                                IFormatter formatter            = null,
                                                Func <Encoding> encodingFactory = null)
 {
     return(StartAsync(channel, DefaultBreathTime, formatter, encodingFactory));
 }