Interface ICharacterGuildService
- Namespace
- FishMMO.Database.Npgsql.Services.Interfaces
- Assembly
- FishMMO-DB.dll
Service interface for managing a character's guild membership state.
public interface ICharacterGuildService : ICountByKeyAction<long>, IDeleteByKeyVersionedAction<long>, IFetchByKeyAction<long, CharacterGuildData?>, IFetchManyByKeyAction<long, CharacterGuildData>
- Inherited Members
Remarks
Guild membership updates should be version-gated via the logical Version
so stale updates are rejected and newer authoritative updates win.
Methods
FetchManyAsync(long[], CancellationToken)
Fetches the rosters of several guilds in one query.
Task<DatabaseResult<IReadOnlyDictionary<long, IReadOnlyList<CharacterGuildData>>>> FetchManyAsync(long[] guildIds, CancellationToken cancellationToken = default)
Parameters
guildIdslong[]The guilds to read. Non-positive and repeated IDs are ignored.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
- Task<DatabaseResult<IReadOnlyDictionary<long, IReadOnlyList<CharacterGuildData>>>>
One entry per distinct requested guild, ALWAYS present: a guild with no membership rows maps to an empty list, as
FetchManyAsync(long)answers for it.
Remarks
For the scene server's guild update pump. It used to read each changed guild's roster in
its own round trip — two, with the ladder — so a login wave touching many guilds cost two
serial queries per guild before any of them could be delivered. Each row carries the same
columns as FetchManyAsync(long), race and last-seen included.
PersistAsync(CharacterGuildData, int, CancellationToken)
Persists the provided guild membership data, enforcing capacity limits.
Task<DatabaseResult> PersistAsync(CharacterGuildData guildData, int maxCapacity, CancellationToken cancellationToken = default)
Parameters
guildDataCharacterGuildDataThe guild membership data to persist.
maxCapacityintThe maximum number of members allowed in the guild.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
- Task<DatabaseResult>
A DatabaseResult indicating success or failure.
UpdateLocationAsync(long, long, string, CancellationToken)
Writes where a member is — the scene name, or "Offline" — without touching anything else.
Task<DatabaseResult<bool>> UpdateLocationAsync(long characterId, long guildId, string location, CancellationToken cancellationToken = default)
Parameters
characterIdlongThe member.
guildIdlongThe guild the member must still belong to.
locationstringThe location label.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
- Task<DatabaseResult<bool>>
True when the member's row was updated; false when the character no longer holds a membership in
guildId— kicked, left, or moved — which is not an error.
Remarks
An UPDATE, never an insert, and the guild is in the WHERE clause. The location used to be written through PersistAsync(CharacterGuildData, int, CancellationToken), a version-gated UPSERT, after reading the row for its version and rank. Between that read and the write a kick could delete the row, and the UPSERT then INSERTED it again: the kicked member was back in the guild, permanently. A write that can only change an existing row cannot do that.
No version bump, like UpdateNoteAsync(long, long, string, bool, CancellationToken). The version arbitrates membership (rank, removal); a location label is not membership, and bumping it would make every rank change or kick that raced a login or logout fail as stale.
UpdateNoteAsync(long, long, string, bool, CancellationToken)
Writes one of a member's two guild notes.
Task<DatabaseResult> UpdateNoteAsync(long characterId, long guildId, string note, bool isOfficerNote, CancellationToken cancellationToken = default)
Parameters
characterIdlongThe member the note is about.
guildIdlongThe guild the note belongs to.
notestringThe note text. Capped at 128 characters.
isOfficerNoteboolTrue for the officer-only note, false for the public one.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
- Task<DatabaseResult>
A DatabaseResult indicating success or failure.
Remarks
The guild is in the WHERE clause. A note request naming a character who has since left — or who was never in the editor's guild — must not write, and this is where that is guaranteed rather than merely checked earlier.
UpdateRankAsync(long, long, byte, long, CancellationToken)
Updates a character's guild rank if incomingVersion is newer.
Task<DatabaseResult> UpdateRankAsync(long characterId, long guildId, byte rank, long incomingVersion, CancellationToken cancellationToken = default)
Parameters
characterIdlongThe character ID.
guildIdlongThe guild ID.
rankbyteThe new rank.
incomingVersionlongThe authoritative, monotonic version for this update operation.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
- Task<DatabaseResult>
A DatabaseResult indicating success or failure.