Class StateStoreUtils
Utilities used in state-storage
Inherited Members
Namespace: Cognite.Extractor.StateStorage
Assembly: Cognite.StateStorage.dll
Syntax
public static class StateStoreUtils
Methods
| Edit this page View SourceAddStateStore(IServiceCollection, params StorageType[])
Configure service collection to include a state store
Declaration
public static void AddStateStore(this IServiceCollection services, params StateStoreConfig.StorageType[] bannedTypes)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services | Servicecollection to add to |
StorageType[] | bannedTypes | List of state-storage types excluded from use. |
BsonToDict(BsonDocument)
Convert a BsonDocument into nested dictionaries.
Declaration
public static IDictionary<string, object> BsonToDict(BsonDocument value)
Parameters
Type | Name | Description |
---|---|---|
BsonDocument | value | BsonDocument to convert |
Returns
Type | Description |
---|---|
IDictionary<string, object> | Converted document |
BuildMapper()
Return a custom LiteDB.BsonMapper used to create Bson for litedb and Json for raw.
Declaration
public static BsonMapper BuildMapper()
Returns
Type | Description |
---|---|
BsonMapper |
DeserializeViaBson<T>(IDictionary<string, JsonElement>, BsonMapper)
Convert a jsonElement dictionary into a bsonDocument, then deserialize to type T
Declaration
public static T DeserializeViaBson<T>(IDictionary<string, JsonElement> raw, BsonMapper mapper)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<string, JsonElement> | raw | Json data |
BsonMapper | mapper | Mapper to use for deserializing |
Returns
Type | Description |
---|---|
T | An instance of |
Type Parameters
Name | Description |
---|---|
T | Type to deserialize to |
StoreStatesPeriodically<K>(IExtractionStateStore, TimeSpan, IEnumerable<K>, string, CancellationToken)
Store a given liste of extraction states with given period.
Declaration
public static Task StoreStatesPeriodically<K>(this IExtractionStateStore store, TimeSpan period, IEnumerable<K> extractionStates, string tableName, CancellationToken token) where K : BaseExtractionState
Parameters
Type | Name | Description |
---|---|---|
IExtractionStateStore | store | This store |
TimeSpan | period | Minimum interval between each time states are stored |
IEnumerable<K> | extractionStates | States to store |
string | tableName | Collection to store into |
CancellationToken | token |
Returns
Type | Description |
---|---|
Task |
Type Parameters
Name | Description |
---|---|
K | Subtype of BaseExtractionState used as state |
StoreStatesPeriodically<T, K>(IExtractionStateStore, TimeSpan, IEnumerable<K>, string, Func<K, T>, CancellationToken)
Store a given liste of extraction states with given period.
Declaration
public static Task StoreStatesPeriodically<T, K>(this IExtractionStateStore store, TimeSpan period, IEnumerable<K> extractionStates, string tableName, Func<K, T> buildStorableState, CancellationToken token) where T : BaseStorableState where K : IExtractionState
Parameters
Type | Name | Description |
---|---|---|
IExtractionStateStore | store | This store |
TimeSpan | period | Minimum interval between each time states are stored |
IEnumerable<K> | extractionStates | States to store |
string | tableName | Collection to store into |
Func<K, T> | buildStorableState | Method to create a storable state from extraction state |
CancellationToken | token |
Returns
Type | Description |
---|---|
Task |
Type Parameters
Name | Description |
---|---|
T | Subtype of BaseStorableState extracted from state store |
K | Implementation of IExtractionState used as state |
ToSnakeCase(string)
Convert PascalCase string into snake-case.
Declaration
public static string ToSnakeCase(this string str)
Parameters
Type | Name | Description |
---|---|---|
string | str | PascalCase string to be converted |
Returns
Type | Description |
---|---|
string | snake-case string |