Table of Contents

Class CharacterWaypointService

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

Persists a character's discovered waypoints as per-scene bitmask pages.

public sealed class CharacterWaypointService : BaseService<CharacterWaypointEntity>, ICharacterWaypointService, IFetchCollectionByKeyAction<long, CharacterWaypointData>, IDeleteByKeyAction<long>
Inheritance
CharacterWaypointService
Implements
Inherited Members

Remarks

The mask travels as ulong in the game and as bigint in PostgreSQL. The conversion is a two's-complement reinterpretation, which is lossless, and it is done in this class only, so nothing above it knows the column is signed. The merge itself is a bitwise OR in SQL — the database, not the application, is where two concurrent writers' bits meet.

Constructors

CharacterWaypointService(INpgsqlDbContextFactory)

public CharacterWaypointService(INpgsqlDbContextFactory dbContextFactory)

Parameters

dbContextFactory INpgsqlDbContextFactory

Methods

DeleteAsync(long, CancellationToken)

Deletes the entity identified by the given key.

public Task<DatabaseResult> DeleteAsync(long characterId, CancellationToken cancellationToken = default)

Parameters

characterId long
cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult>

Remarks

Character deletion only. Hard-deletes every page the character has.

FetchAsync(long, CancellationToken)

Fetches a collection of items for the given key.

public Task<DatabaseResult<IReadOnlyList<CharacterWaypointData>>> FetchAsync(long characterId, CancellationToken cancellationToken = default)

Parameters

characterId long
cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult<IReadOnlyList<CharacterWaypointData>>>

MergeAsync(IEnumerable<CharacterWaypointData>, CancellationToken)

OR-merges pages into the stored masks, creating rows that do not exist yet.

public Task<DatabaseResult> MergeAsync(IEnumerable<CharacterWaypointData> pages, CancellationToken cancellationToken = default)

Parameters

pages IEnumerable<CharacterWaypointData>

The pages to merge. Bits already stored are retained.

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, or two scene servers writing during a transfer, converge on the union. A bit can never be cleared through this call; a character does not un-discover a place.