Show / Hide Table of Contents

Class ConfigurationExtensions

Extension utilities for configuration.

Inheritance
object
ConfigurationExtensions
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Cognite.Extractor.Utils
Assembly: ExtractorUtils.dll
Syntax
public static class ConfigurationExtensions

Methods

| Edit this page View Source

AddConfig<T>(IServiceCollection, string, params int[]?)

Read the config of type T from the yaml file in path and adds it as a singleton to the service collection services Also adds CogniteConfig, LoggerConfig and MetricsConfig configuration objects as singletons, if they are present in the configuration

Declaration
public static T AddConfig<T>(this IServiceCollection services, string path, params int[]? acceptedConfigVersions) where T : VersionedConfig
Parameters
Type Name Description
IServiceCollection services

The service collection

string path

Path to the file

int[] acceptedConfigVersions

Accepted versions

Returns
Type Description
T

An instance of the configuration object

Type Parameters
Name Description
T

A type that inherits from Cognite.Extractor.Configuration.VersionedConfig

Exceptions
Type Condition
ConfigurationException

Thrown when the version is not valid, the yaml file is not found or in case of yaml parsing error

| Edit this page View Source

AddConfig<T>(IServiceCollection, string, Type[], params int[]?)

Read the config of type T from the yaml file in path and adds it as a singleton to the service collection services Also adds CogniteConfig, LoggerConfig and MetricsConfig configuration objects as singletons, if they are present in the configuration

Declaration
public static T AddConfig<T>(this IServiceCollection services, string path, Type[] types, params int[]? acceptedConfigVersions) where T : VersionedConfig
Parameters
Type Name Description
IServiceCollection services

The service collection

string path

Path to the file

Type[] types

Types to look for as properties on T

int[] acceptedConfigVersions

Accepted versions

Returns
Type Description
T

An instance of the configuration object

Type Parameters
Name Description
T

A type that inherits from Cognite.Extractor.Configuration.VersionedConfig

Exceptions
Type Condition
ConfigurationException

Thrown when the version is not valid, the yaml file is not found or in case of yaml parsing error

| Edit this page View Source

AddExtractionRun(IServiceCollection, bool)

Add an ExtractionRun object as singleton dependency.

Declaration
public static void AddExtractionRun(this IServiceCollection services, bool setLogger)
Parameters
Type Name Description
IServiceCollection services

Service collection to add to

bool setLogger

True to set a logger

| Edit this page View Source

AddExtractorDependencies<T>(IServiceCollection, string?, int[]?, string?, string?, bool, bool, bool, bool, T?, Func<LoggerConfig, ILogger>?, IEnumerable<Type>?, bool)

Configure dependencies for the BaseExtractor, adding metrics, logging, state store and cognite client. Short for AddConfig, AddCogniteClient, AddStateStore, AddMetrics and AddLogger.

Declaration
public static T AddExtractorDependencies<T>(this IServiceCollection services, string? configPath, int[]? acceptedConfigVersions, string? appId, string? userAgent, bool addStateStore, bool addLogger = true, bool addMetrics = true, bool requireDestination = true, T? config = null, Func<LoggerConfig, ILogger>? buildLogger = null, IEnumerable<Type>? types = null, bool doNotAddConfig = false) where T : VersionedConfig
Parameters
Type Name Description
IServiceCollection services

Servicecollection to add to

string configPath

Path to config file

int[] acceptedConfigVersions

Valid config versions. Can be null to allow all.

string appId

AppId added to requests to CDF

string userAgent

User agent on form Product/Version

bool addStateStore

True to add state store, used if extractor reads history

bool addLogger

True to add logger

bool addMetrics

True to add metrics

bool requireDestination

True to fail if a destination cannot be configured

T config

Optional pre-defined config object to use instead of reading from file

Func<LoggerConfig, ILogger> buildLogger

Optional method to build logger. Types to look for as properties on T Skip adding config to the service collection, for example if it has already been added by AddRemoteConfig. Defaults to GetConfiguredLogger(LoggerConfig)

IEnumerable<Type> types
bool doNotAddConfig
Returns
Type Description
T

Configuration object

Type Parameters
Name Description
T

Type of config object

Exceptions
Type Condition
ConfigurationException

Thrown when the version is not valid, the yaml file is not found or in case of yaml parsing error

| Edit this page View Source

AddRemoteConfig<T>(IServiceCollection, ILogger?, string?, IEnumerable<Type>?, string?, string?, bool, bool, RemoteConfig?, CancellationToken, params int[]?)

Read the config of type T from the yaml file in path, or if the "type" field is set to "remote", read a minimal config file with just CogniteConfig, then use that to fetch the config file from the configured extraction pipeline. Either way it adds a config object to services. Also adds CogniteConfig, LoggerConfig and MetricsConfig configuration objects as singletons, if they are present in the configuration. The RemoteConfigManager is added as a service to the service collection, and can be used to check for updates to configuration later.

Declaration
public static Task<T> AddRemoteConfig<T>(this IServiceCollection services, ILogger? logger, string? path, IEnumerable<Type>? types, string? appId, string? userAgent, bool setDestination, bool bufferConfigFile, RemoteConfig? remoteConfig, CancellationToken token, params int[]? acceptedConfigVersions) where T : VersionedConfig
Parameters
Type Name Description
IServiceCollection services

The service collection

ILogger logger

Logger to use during startup

string path

Path to the file

IEnumerable<Type> types

Types to look for as properties on T

string appId

Optional appid

string userAgent

Optional user agent

bool setDestination

Create a cognite destination based on remote config, or assume one is already provided.

bool bufferConfigFile

True to store the configuration file locally so that the extractor may start even without a connection to CDF. Stored in the same directory as the config file, with name equal to temp[name-of-config-file]

RemoteConfig remoteConfig

Pre-existing config object, set to null to read from path instead. Path is still required if bufferConfigFile is set.

CancellationToken token

Optional cancellation token.

int[] acceptedConfigVersions

Accepted versions

Returns
Type Description
Task<T>

An instance of the configuration object

Type Parameters
Name Description
T

A type that inherits from Cognite.Extractor.Configuration.VersionedConfig

Exceptions
Type Condition
ConfigurationException

Thrown when the version is not valid, the yaml file is not found or in case of yaml parsing error

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX