public async Task Test_logging_output() { var random = new Random(); var reporter = new OrphanedResponseLogger { Interval = 100 }; foreach (var i in Enumerable.Range(1, 100)) { var context = OperationContext.CreateKvContext((uint)i); context.ConnectionId = "connection-id"; context.BucketName = "default"; context.LocalEndpoint = "192.168.1.1:16212"; context.RemoteEndpoint = "cb-1.domain.com"; context.ServerDuration = random.Next(10, 100); reporter.Add(context); await Task.Delay(10); } await Task.Delay(10000); reporter.Dispose(); }
private static OperationContext CreateOperationContext(SocketAsyncState state, long?serverDuration, string bucketName = null) { var context = OperationContext.CreateKvContext(state.Opaque); context.ConnectionId = state.ConnectionId; context.LocalEndpoint = state.LocalEndpoint; context.RemoteEndpoint = state.EndPoint.ToString(); context.TimeoutMicroseconds = (uint)state.Timeout * 1000; // convert millis to micros if (serverDuration.HasValue) { context.ServerDuration = serverDuration; } if (!string.IsNullOrWhiteSpace(bucketName)) { context.BucketName = bucketName; } return(context); }
protected OperationContext CreateOperationContext(uint opaque) { var context = OperationContext.CreateKvContext(opaque); context.ConnectionId = ContextId; if (Configuration != null) { context.BucketName = Configuration.BucketName; context.TimeoutMicroseconds = (uint)Configuration.SendTimeout * 1000; // convert millis to micros } if (LocalEndPoint != null) { context.LocalEndpoint = LocalEndPoint.ToString(); } if (EndPoint != null) { context.RemoteEndpoint = EndPoint.ToString(); } return(context); }