public static IClusterClient Get( string environmentName, int defaultRequestTimeoutMs, IWebProxy?proxy = null, ILog?log = null, ITracer?tracer = null ) { if (string.IsNullOrEmpty(environmentName)) { throw new ArgumentOutOfRangeException(nameof(environmentName)); } return(new ClusterClient(log, configuration => { configuration.DefaultTimeout = TimeSpan.FromMilliseconds(defaultRequestTimeoutMs); configuration.SetupSingular(new SingularClientSettings(environmentName, "Catalogue_EDI_API_Front")); configuration.SetupUniversalTransport( new UniversalTransportSettings { AllowAutoRedirect = false, Proxy = proxy }); if (tracer != null) { configuration.SetupDistributedTracing(tracer); } })); }
public RabbitMQService( Models.RabbitMQSettings settings, ITracer?tracer = default) { _tracer = tracer; using var scope = _tracer?.StartSpan(); scope?.Span.Log(settings); try { Guard.Argument(() => settings).NotNull(); Guard.Argument(() => settings.HostName).NotNull().NotEmpty().NotWhiteSpace(); Guard.Argument(() => settings.Port).InRange(1, 65_535); Guard.Argument(() => settings.UserName).NotNull().NotEmpty().NotWhiteSpace(); Guard.Argument(() => settings.Password, secure: true).NotNull().NotEmpty().NotWhiteSpace(); Guard.Argument(() => settings.VirtualHost).NotNull().NotEmpty().NotWhiteSpace(); } catch (Exception ex) { scope?.Span.Log(ex); throw; } _connectionFactory = new ConnectionFactory { HostName = settings.HostName, Port = settings.Port, UserName = settings.UserName, Password = settings.Password, VirtualHost = settings.VirtualHost, }; }
protected WebClientBase( ILogger?logger = default, ITracer?tracer = default) { _logger = logger; _tracer = tracer; _httpMessageInvoker = new HttpClient(); }
protected WebClientBase( IHttpClientFactory httpClientFactory, ILogger?logger = default, ITracer?tracer = default) : this(logger, tracer) { _httpMessageInvoker = httpClientFactory.CreateClient(this.GetType().Name); }
protected WebClientBase( HttpClient httpClient, ILogger?logger = default, ITracer?tracer = default) : this(logger, tracer) { _httpMessageInvoker = Guard.Argument(httpClient).NotNull().Value; }
protected BaseEdiApiHttpClient( string apiClientId, string environment, IEdiApiTypesSerializer serializer, int timeoutInMilliseconds, IWebProxy?proxy = null, ITracer?tracer = null) { this.apiClientId = apiClientId; Serializer = serializer; clusterClient = ClusterClientFactory.Get(environment, timeoutInMilliseconds, proxy, tracer: tracer); }
/// <summary> /// Initialize a new instance of a generic ADO transaction. Use /// a provider-specific subclass for better performance. /// </summary> /// <param name="connectionFactory">Factory to create connections for current database.</param> /// <param name="parameterMapper">Provides parameter value from input object instances.</param> /// <param name="tracer">The OpenTracing tracer instance to use. If this value is null the global tracer will /// be used instead.</param> public SqlCommandManager( IConnectionFactory connectionFactory, IParameterMapper parameterMapper, ITracer?tracer) { _connectionFactory = connectionFactory; ParameterMapper = parameterMapper; _tracer = tracer ?? GlobalTracer.Instance; }
public SlackClient( IOptions <Models.Settings> settingsOptions, ILogger?logger = default, ITracer?tracer = default) : base(new ClientFactory(), logger, tracer) { _token = Guard.Argument(() => settingsOptions).NotNull() .Wrap(o => o.Value).NotNull() .Wrap(o => o.Token !).NotNull().NotEmpty().NotWhiteSpace().Value; _webhookSegments = Guard.Argument(() => settingsOptions).NotNull() .Wrap(o => o.Value).NotNull() .Wrap(s => s.WebhookSegments !).NotNull().NotEmpty().DoesNotContainNull().Value; }
private void ApplyProblemDetailsDefaults(HttpContext httpContext, ProblemDetails problemDetails, int statusCode) { if (this.options.ClientErrorMapping.TryGetValue(statusCode, out ClientErrorData? clientErrorData)) { problemDetails.Title ??= clientErrorData.Title; problemDetails.Type ??= clientErrorData.Link; } ITracer?tracer = httpContext.RequestServices?.GetService <ITracer>(); if (tracer != null && tracer.ActiveSpan is ISpan span) { problemDetails.Extensions["traceId"] = span.Context.TraceId; } }
public DiscordClient( IHttpClientFactory httpClientFactory, IOptions <Models.Webhook> webhookOptions, ILogger?logger = default, ITracer?tracer = default) : base(httpClientFactory, logger, tracer) { var webhook = Guard.Argument(() => webhookOptions).NotNull().Value.Value; Guard.Argument(() => webhook).NotNull(); Guard.Argument(() => webhook.Id).InRange(1, long.MaxValue); Guard.Argument(() => webhook.Token !).NotNull().NotEmpty().NotWhiteSpace().Matches(@"^[-0-9A-Z_a-z]{68}$"); _relativeUri = new Uri($"/api/webhooks/{webhook.Id:D}/{webhook.Token}", UriKind.Relative); }
/// <summary> /// Creates command parameters for an Oracle database reference. /// </summary> /// <param name="connectionFactory"> /// A connection factory that returns an Oracle DB connection. /// </param> /// <param name="parameterMapper">The parameter mapper.</param> /// <param name="tracer">The OpenTracing tracer instance to use. If this value is null the global tracer will /// be used instead.</param> public OracleDatabase(IConnectionFactory connectionFactory, IParameterMapper?parameterMapper, ITracer?tracer) : base(new SqlCommandManager(connectionFactory, parameterMapper ?? new DefaultParameterMapper(), tracer), new OracleDialect()) { }
public InternalEdiApiHttpClient(string apiClientId, string environment, IEdiApiTypesSerializer serializer, int timeoutInMilliseconds = DefaultTimeout, IWebProxy?proxy = null, ITracer?tracer = null) : base(apiClientId, environment, serializer, timeoutInMilliseconds, proxy, tracer) { }
/// <summary> /// Creates command parameters for a SQLite connection. /// </summary> /// <param name="connectionString">The connection string.</param> /// <param name="parameterMapper">The parameter mapper.</param> /// <param name="tracer"> /// The OpenTracing tracer instance to use. If this value is null the global tracer will /// be used instead. /// </param> public SqliteDatabase(string connectionString, IParameterMapper?parameterMapper, ITracer?tracer) : base(new SqlCommandManager(new SqliteConnectionFactory(connectionString), parameterMapper ?? new DefaultParameterMapper(), tracer), new SqliteDialect()) { }
public MessagesEdiApiHttpClient(string apiClientId, string environment, int timeoutInMilliseconds = DefaultTimeout, IWebProxy?proxy = null, ITracer?tracer = null) : this(apiClientId, environment, new JsonEdiApiTypesSerializer(), timeoutInMilliseconds, proxy, tracer) { }
public static void Register(ILogger?logger, ITracer?tracer) => WindowsHidDeviceFactory.Register(logger, tracer);