Class BaseUploadQueue<T>
Generic base class for upload queues
Inherited Members
Namespace: Cognite.Extractor.Utils
Assembly: ExtractorUtils.dll
Syntax
public abstract class BaseUploadQueue<T> : IUploadQueue<T>, IUploadQueue, IDisposable, IAsyncDisposable
Type Parameters
Name | Description |
---|---|
T |
Constructors
| Edit this page View SourceBaseUploadQueue(CogniteDestination, TimeSpan, int, ILogger, Func<QueueUploadResult<T>, Task>?)
Constructor
Declaration
protected BaseUploadQueue(CogniteDestination destination, TimeSpan interval, int maxSize, ILogger logger, Func<QueueUploadResult<T>, Task>? callback)
Parameters
Type | Name | Description |
---|---|---|
CogniteDestination | destination | Cognite destination used for uploads |
TimeSpan | interval | Maximum interval between uploads. Set to zero or Timeout.InfiniteTimeSpan to disable periodic uploads |
int | maxSize | Maximum size of the upload queue, once it reaches this size an upload will always be triggered |
ILogger | logger | Logger to use |
Func<QueueUploadResult<T>, Task> | callback | Callback on finished upload, whether it failed or not |
Properties
| Edit this page View SourceCallback
Callback on upload
Declaration
protected Func<QueueUploadResult<T>, Task>? Callback { get; }
Property Value
Type | Description |
---|---|
Func<QueueUploadResult<T>, Task> |
DestLogger
Logger to use
Declaration
protected ILogger DestLogger { get; }
Property Value
Type | Description |
---|---|
ILogger |
Destination
CogniteDestination to use
Declaration
protected CogniteDestination Destination { get; }
Property Value
Type | Description |
---|---|
CogniteDestination |
Methods
| Edit this page View SourceDequeue()
Empty the queue and return the contents
Declaration
public virtual IEnumerable<T> Dequeue()
Returns
Type | Description |
---|---|
IEnumerable<T> | Contents of the queue |
Dispose()
Dispose of the queue, uploading all remaining entries. Use DisposeAsync instead if possible.
Declaration
public void Dispose()
Dispose(bool)
Dispose of the queue, uploading all remaining entries.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing |
DisposeAsync()
Dispose of the queue, uploading all remaining entries. Preferred over synchronous dispose.
Declaration
public ValueTask DisposeAsync()
Returns
Type | Description |
---|---|
ValueTask |
DisposeAsyncCore()
Internal method to dispose asynchronously.
Declaration
protected ValueTask DisposeAsyncCore()
Returns
Type | Description |
---|---|
ValueTask |
Enqueue(IEnumerable<T>)
Enqueue a list of items in the internal queue.
Declaration
public virtual void Enqueue(IEnumerable<T> items)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | items | Items to enqueue |
Enqueue(T)
Enqueue a single item in the internal queue.
Declaration
public virtual void Enqueue(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | Item to enqueue |
Start(CancellationToken)
Start automatically uploading queue entries
Declaration
public Task Start(CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | token |
Returns
Type | Description |
---|---|
Task |
Trigger(CancellationToken)
Trigger queue upload and return the result instead of calling the callback. Can be used as alternative for callback entirely.
Declaration
public Task<QueueUploadResult<T>> Trigger(CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | token |
Returns
Type | Description |
---|---|
Task<QueueUploadResult<T>> | A QueueUploadResult<T> containing an error or the uploaded entries |
UploadEntries(IEnumerable<T>, CancellationToken)
Method called to upload entries
Declaration
protected abstract Task<QueueUploadResult<T>> UploadEntries(IEnumerable<T> items, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | items | Items to upload |
CancellationToken | token |
Returns
Type | Description |
---|---|
Task<QueueUploadResult<T>> | A QueueUploadResult<T> containing an error or the uploaded entries |