Interface IAsyncJobQueue<TAsyncEnumerable, T>
A queue for long-existing System.Collections.Generic.IAsyncEnumerable<T> that represent a collection of long running resumable jobs. This variant allows for higher-kinded implementations of System.Collections.Generic.IAsyncEnumerable<T>.
Inherited Members
Namespace: Snowflake.Extensibility.Queueing
Assembly: Snowflake.Framework.Primitives.dll
Syntax
public interface IAsyncJobQueue<TAsyncEnumerable, T> : IAsyncJobQueue where TAsyncEnumerable : class, IAsyncEnumerable<T>
Type Parameters
| Name | Description |
|---|---|
| TAsyncEnumerable | The type that implements System.Collections.Generic.IAsyncEnumerable<T> |
| T | The type of elements in the enumerable. |
Methods
AsEnumerable(Guid)
Gets the remaining values in the enumerator as an System.Collections.Generic.IAsyncEnumerable<T> that can be looped on.
Looping on this will exhaust the enumerator, and therefore using
Declaration
IAsyncEnumerable<T> AsEnumerable(Guid jobId)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
jobId | The job token that was returned by Queue |
Returns
| Type | Description |
|---|---|
| System. |
The remaining values in the enumerator as an System.Collections.Generic.IAsyncEnumerable<T> |
GetCurrent(Guid)
Retrieves the current value in the enumerator and whether or not the enumerator is exhausted.
Once the enumerator is exhausted, the value field will always be default(T),
and hasNext will be false.
Declaration
T GetCurrent(Guid jobId)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
jobId | The job token that was returned by Queue |
Returns
| Type | Description |
|---|---|
| T | The value, or null if the current value is null. |
GetNext(Guid)
Retrieves the next value in the enumerator and whether or not the enumerator is exhausted.
Once the enumerator is exhausted, the value field will always be default(T),
and movedNext will be false.
Declaration
ValueTask<(T value, bool movedNext)> GetNext(Guid jobId)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
jobId | The job token that was returned by Queue |
Returns
| Type | Description |
|---|---|
| System. |
The next value and whether or not to continue iterating. |
GetSource(Guid)
Get the System.Collections.Generic.IAsyncEnumerable<T> as it was added to the job queue.
Declaration
TAsyncEnumerable GetSource(Guid jobId)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
jobId | The jobId |
Returns
| Type | Description |
|---|---|
| TAsync |
The System.Collections.Generic.IAsyncEnumerable<T> as it was added to the job queue. |
QueueJob(TAsyncEnumerable)
Declaration
ValueTask<Guid> QueueJob(TAsyncEnumerable asyncEnumerable)
Parameters
| Type | Name | Description |
|---|---|---|
| TAsync |
asyncEnumerable |
Returns
| Type | Description |
|---|---|
| System. |
QueueJob(TAsyncEnumerable, Guid)
Queues an System.Collections.Generic.IAsyncEnumerable<T> into the job queue with your own job token. If this job token already exists, this will replace the old job, which will be disposed.
Declaration
ValueTask<Guid> QueueJob(TAsyncEnumerable asyncEnumerable, Guid guid)
Parameters
| Type | Name | Description |
|---|---|---|
| TAsync |
asyncEnumerable | The System.Collections.Generic.IAsyncEnumerable<T> to persist in memory. |
| System. |
guid | A token to refer to the job at a later time. |
Returns
| Type | Description |
|---|---|
| System. |
The System. |
TryRemoveSource(Guid, out TAsyncEnumerable)
Tries to remove the System.Collections.Generic.IAsyncEnumerable<T> as it was added to the job queue. This will only succeed if there are no active jobs for the enumerable in the queue, and it was not automatically disposed.
If not automatically disposed, this means that the enumerable
must be exhausted or cancelled with Request
Declaration
bool TryRemoveSource(Guid jobId, out TAsyncEnumerable asyncEnumerable)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
jobId | The jobId |
| TAsync |
asyncEnumerable | The async enumerable that is removed, or null if the result is false. |
Returns
| Type | Description |
|---|---|
| System. |
If the enumerable was successfully removed. |