public Exploration RunExploration( string dataSource, string table, IEnumerable <string> columns, Uri?apiUri = null, string?apiKey = null) { apiUri ??= TestApiUri; apiKey ??= string.Empty; // Register the authentication token for this scope. // Note that in most test cases the api key will not be needed as it will be provided from // the environment (via a `StaticApiKeyAuthProvider`) if (scopedContainer.GetInstance <IAircloakAuthenticationProvider>() is ExplorerApiAuthProvider auth) { auth.RegisterApiKey(apiKey); } var testParams = new Models.ExploreParams { ApiUrl = apiUri.AbsoluteUri, DataSource = dataSource, Table = table, Columns = ImmutableArray.Create(columns.ToArray()), }; var exploration = new Exploration((IContainer)scopedContainer, new TypeBasedScopeBuilder()); exploration.Explore(scopedContainer.GetInstance <JsonApiContextBuilder>(), testParams); return(exploration); }
public ColumnExploration(ExplorationConfig config, INestedContainer scope, string column) { this.scope = scope; publisher = scope.GetInstance <MetricsPublisher>(); Column = column; Completion = Task.WhenAll(config.Tasks); }
public static void InjectDisposable <T>(this INestedContainer nc, T instance, bool replace = false) { if (replace && nc.GetInstance <T>() is IDisposable old) { old.Dispose(); } nc.Inject(instance, replace); ((Scope)nc).TryAddDisposable(instance); }
public static T ResolvePublisherComponent <T>(this INestedContainer scope) where T : PublisherComponent { // Try to resolve using the PublisherComponent interface. If this doesn't work, auto-resolve // the concrete instance instead. var fromCollection = (T)scope.TryGetInstance <PublisherComponent>(typeof(T).NameInCode()); return(fromCollection ?? scope.GetInstance <T>()); }
public void AddPublisher <T>(Action <T>?configure = null) where T : PublisherComponent { var component = scope.ResolvePublisherComponent <T>(); configure?.Invoke(component); var metricsPublisher = scope.GetInstance <MetricsPublisher>(); Tasks.Add(component.PublishMetrics(metricsPublisher)); }
public MessageHandlerScope(INestedContainer nestedContainer, Type handlerType) { _nestedNestedContainer = nestedContainer; Handler = (IMessageHandler)nestedContainer.GetInstance(handlerType); }
public T GetInstance <T>() => _lamarContainer.GetInstance <T>();
protected override IPublishEndpoint GetPublishEndpoint() { return(_childContainer.GetInstance <IPublishEndpoint>()); }
protected override ISendEndpointProvider GetSendEndpointProvider() { return(_childContainer.GetInstance <ISendEndpointProvider>()); }
public ExplorationScope(INestedContainer scope) { this.scope = scope; logger = scope.GetInstance <ILogger <ExplorationScope> >(); }
protected override IRequestClient <SimpleMessageClass> GetSendRequestClient() { return(_childContainer.GetInstance <IRequestClient <SimpleMessageClass> >()); }