Table of Contents

Class WorldPortalStateService

Namespace
FishMMO.Database.Npgsql.Services
Assembly
FishMMO-DB.dll

Persists portals opened for the whole world: one row per (scene, portal index).

public sealed class WorldPortalStateService : BaseService<WorldPortalStateEntity>, IWorldPortalStateService, IFetchCollectionByKeyAction<string, WorldPortalStateData>
Inheritance
WorldPortalStateService
Implements
Inherited Members

Remarks

The merge is done in SQL so two scene servers opening the same portal at once converge: permanent ORs and active_until takes GREATEST, never the newer write.

Constructors

WorldPortalStateService(INpgsqlDbContextFactory)

public WorldPortalStateService(INpgsqlDbContextFactory dbContextFactory)

Parameters

dbContextFactory INpgsqlDbContextFactory

Methods

FetchAsync(string, CancellationToken)

Fetches a collection of items for the given key.

public Task<DatabaseResult<IReadOnlyList<WorldPortalStateData>>> FetchAsync(string sceneName, CancellationToken cancellationToken = default)

Parameters

sceneName string
cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult<IReadOnlyList<WorldPortalStateData>>>

MergeAsync(IEnumerable<WorldPortalStateData>, CancellationToken)

Merges openings into the stored rows: permanent ORs and active_until takes the later moment. Creates rows that do not exist yet.

public Task<DatabaseResult> MergeAsync(IEnumerable<WorldPortalStateData> states, CancellationToken cancellationToken = default)

Parameters

states IEnumerable<WorldPortalStateData>

The openings to merge.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult>

Success, or the failure that stopped the whole batch.

Remarks

Idempotent: a retry after an ambiguous failure changes nothing.