Class FederationQueue
Outgoing transactions, one queue per destination server: PDUs and EDUs are batched, and retried with growing pauses while the server cannot be reached.
Implements
Inherited Members
Namespace: Uniform.Matrix.Server.Federation
Assembly: Uniform.Matrix.Server.dll
Syntax
public sealed class FederationQueue : IDisposable
Remarks
PDUs and the EDUs that still matter later, such as to-device messages with room keys, are also kept in FederationOutboxRows and sent after a restart, see ResumeAsync(CancellationToken); typing and presence are in memory only, as they are stale by then. A refusal of the other server, other than 429, drops the batch, as sending it again would be refused again. Each queue is bounded; when full, its oldest EDUs and then PDUs go first. With federation off, queues wait.
Constructors
| Edit this page View SourceFederationQueue(FederationClient, IDbContextFactory<ServerDbContext>, IOptionsMonitor<FederationOptions>, IOptionsMonitor<ServerOptions>, TimeProvider, ILogger<FederationQueue>)
Create the queues.
Declaration
public FederationQueue(FederationClient federation, IDbContextFactory<ServerDbContext> contexts, IOptionsMonitor<FederationOptions> options, IOptionsMonitor<ServerOptions> server, TimeProvider time, ILogger<FederationQueue> logger)
Parameters
| Type | Name | Description |
|---|---|---|
| FederationClient | federation | |
| IDbContextFactory<ServerDbContext> | contexts | |
| IOptionsMonitor<FederationOptions> | options | |
| IOptionsMonitor<ServerOptions> | server | |
| TimeProvider | time | |
| ILogger<FederationQueue> | logger |
Fields
| Edit this page View SourceFirstRetry
Pause before the first retry; it doubles after each failure.
Declaration
public static readonly TimeSpan FirstRetry
Field Value
| Type | Description |
|---|---|
| TimeSpan |
MaxEdus
Most EDUs in one transaction, as the spec allows.
Declaration
public const int MaxEdus = 100
Field Value
| Type | Description |
|---|---|
| int |
MaxPdus
Most PDUs in one transaction, as the spec allows.
Declaration
public const int MaxPdus = 50
Field Value
| Type | Description |
|---|---|
| int |
MaxRetry
Longest pause between retries.
Declaration
public static readonly TimeSpan MaxRetry
Field Value
| Type | Description |
|---|---|
| TimeSpan |
Methods
| Edit this page View SourceDispose()
Stop the sending loops; what is stored waits for the next start.
Declaration
public void Dispose()
EnqueueEdu(string, JsonObject)
Queue an EDU, e.g. {"edu_type": "m.typing", "content": {...}}, for destination; kept across restarts unless it is typing or presence.
Declaration
public void EnqueueEdu(string destination, JsonObject edu)
Parameters
| Type | Name | Description |
|---|---|---|
| string | destination | |
| JsonObject | edu |
EnqueuePdu(string, JsonObject)
Queue a PDU for destination, kept across restarts.
Declaration
public void EnqueuePdu(string destination, JsonObject pdu)
Parameters
| Type | Name | Description |
|---|---|---|
| string | destination | |
| JsonObject | pdu |
GetQueued(string)
Return how many PDUs and EDUs wait for destination.
Declaration
public (int Pdus, int Edus) GetQueued(string destination)
Parameters
| Type | Name | Description |
|---|---|---|
| string | destination |
Returns
| Type | Description |
|---|---|
| (int Pdus, int Edus) |
ResumeAsync(CancellationToken)
Queue what was waiting when the server stopped; call once at start.
Declaration
public Task ResumeAsync(CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |