Esempio n. 1
0
 public LoggingOptions(
     INaosServicesContext context,
     LoggerConfiguration loggerConfiguration)
 {
     this.Context             = context;
     this.LoggerConfiguration = loggerConfiguration;
 }
Esempio n. 2
0
        public static INaosServicesContext AddAzureLogAnalytics(this INaosServicesContext context, string logName)
        {
            EnsureArg.IsNotNull(context, nameof(context));
            EnsureArg.IsNotNull(context.Services, nameof(context.Services));

            var configuration = context.Configuration?.GetSection("naos:operations:logging:azureLogAnalytics").Get <LogAnalyticsConfiguration>(); // TODO: move to operations:logevents:azureLogAnalytics

            if (configuration != null)
            {
                context.Services.AddScoped <ILogEventRepository>(sp =>
                {
                    // authenticate api https://dev.int.loganalytics.io/documentation/1-Tutorials/ARM-API
                    var token = new AuthenticationContext(
                        $"https://login.microsoftonline.com/{configuration.ApiAuthentication?.TenantId}", false)
                                .AcquireTokenAsync(
                        configuration.ApiAuthentication?.Resource ?? "https://management.azure.com",
                        new ClientCredential(
                            configuration.ApiAuthentication?.ClientId,
                            configuration.ApiAuthentication?.ClientSecret)).Result;

                    return(new LogAnalyticsRepository(
                               sp.GetRequiredService <ILoggerFactory>(),
                               new System.Net.Http.HttpClient(), // TODO: resolve from container!
                               token?.AccessToken,
                               configuration.SubscriptionId,
                               configuration.ResourceGroupName,
                               configuration.WorkspaceName,
                               $"{logName.Replace("_CL", string.Empty)}_CL"));
                });
                context.Messages.Add($"{LogEventKeys.Startup} naos services builder: logging azure loganalytics repository added (name={logName}_CL, workspace={configuration.WorkspaceId})");
            }

            return(context);
        }
Esempio n. 3
0
        public static INaosServicesContext AddServiceClient(this INaosServicesContext context, string name, Action <IHttpClientBuilder> setupAction = null)
        {
            EnsureArg.IsNotNull(context, nameof(context));
            EnsureArg.IsNotNullOrEmpty(name, nameof(name));

            context.Messages.Add($"{LogKeys.Startup} naos services builder: named service client added (name={name})");

            if (setupAction != null)
            {
                var builder = context.Services
                              .AddHttpClient(name);
                setupAction.Invoke(builder);
            }
            else
            {
                // default setup
                context.Services
                .AddHttpClient(name)
                .AddNaosMessageHandlers()
                .AddNaosPolicyHandlers();
            }

            return(context);
        }
Esempio n. 4
0
        public static INaosServicesContext AddServiceClient <TClient>(this INaosServicesContext context, Action <IHttpClientBuilder> setupAction = null)
            where TClient : ServiceDiscoveryClient
        {
            EnsureArg.IsNotNull(context, nameof(context));

            context.Messages.Add($"{LogKeys.Startup} naos services builder: typed service client added (type={typeof(TClient).Name})");

            if (setupAction != null)
            {
                var builder = context.Services
                              .AddHttpClient <TClient>();
                setupAction.Invoke(builder);
            }
            else
            {
                // default setup
                context.Services
                .AddHttpClient <TClient>()
                .AddNaosMessageHandlers()
                .AddNaosPolicyHandlers();
            }

            return(context);
        }
Esempio n. 5
0
 public JobSchedulingOptions(INaosServicesContext context)
 {
     this.Context = context;
 }
Esempio n. 6
0
 public CommandsOptions(INaosServicesContext context)
 {
     this.Context = context;
 }
 public ServiceDiscoveryOptions(INaosServicesContext context)
 {
     this.Context = context;
 }
Esempio n. 8
0
 public NaosServicesContextOptions(INaosServicesContext context)
 {
     this.Context = context;
 }
Esempio n. 9
0
 public QueueingOptions(INaosServicesContext context)
 {
     this.Context = context;
 }
Esempio n. 10
0
 public MessagingOptions(INaosServicesContext context)
 {
     this.Context = context;
 }
 public RequestStorageOptions(INaosServicesContext context)
 {
     this.Context = context;
 }
Esempio n. 12
0
 public OperationsOptions(INaosServicesContext context)
 {
     this.Context = context;
 }