@@ -17,14 +17,14 @@ A library containing utilities for building extractors in .Net
1717
1818The Cognite Extractor Utils can be downloaded from [ NuGet] ( https://www.nuget.org/packages/Cognite.ExtractorUtils ) .
1919
20- To create a console application and add the ** 1.0.0-alpha-011 ** version of library:
20+ To create a console application and add the ** 1.0.0-alpha-017 ** version of library:
2121
2222Using .NET CLI:
2323``` sh
2424mkdir NewExtractor
2525cd NewExtractor
2626dotnet new console
27- dotnet add package Cognite.ExtractorUtils -v 1.0.0-alpha-011
27+ dotnet add package Cognite.ExtractorUtils -v 1.0.0-alpha-017
2828```
2929## Quickstart
3030
@@ -147,6 +147,35 @@ using (var queue = destination.CreateRawUploadQueue<ColumnsDto>("myDb", "myTable
147147
148148` ` `
149149
150+ # # Using the State Store
151+ ` ` ` c#
152+ services.AddStateStore();
153+
154+ using (var provider = services.BuildServiceProvider()) {
155+ var stateStore = provider.GetRequiredService<IExtractionStateStore>();
156+ var destination = provider.GetRequiredService<CogniteDestination>();
157+
158+ // Create a state for a node
159+ var myState = new BaseExtractionState("myState");
160+ var states = new [] { myState };
161+ var stateDict = states.ToDictionary(state => state.Id);
162+
163+ await stateStore.RestoreExtarctionState(stateDict, "someTableorcollection", cancellationToken)
164+
165+ // After uploading points cdf, update the ranges in your state
166+ var now = DateTime.UtcNow;
167+ var datapoints = new Dictionary<Identity, IEnumerable<Datapoint>>() {
168+ { new Identity("myState"), new Datapoint[] { new Datapoint(now - TimeSpan.FromHours(2), "B"), new Datapoint(now, "A")}}}
169+
170+ await destination.InsertDataPointsIgnoreErrorsAsync(datapoints, cancellationToken);
171+
172+ myState.UpdateDestinationRanges(now - TimeSpan.FromHours(2), now);
173+
174+ await stateStore.StoreExtractionState(states, "someTableorcollection", cancellationToken);
175+ // If the extractor stops here, the state is saved and can be restored after restart.
176+ }
177+ ` ` `
178+
150179# Code of Conduct
151180
152181This project follows https://www.contributor-covenant.org
0 commit comments