Table of Contents

Class CharacterPetBuffService

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

Service for managing character pet buffs in the database. Provides async operations for CRUD operations on character pet buff data. Uses the BaseService execution strategy for automatic retry on transient database failures. Returns DatabaseResult for consistent, safe error handling.

public sealed class CharacterPetBuffService : BaseService<CharacterPetBuffEntity>, ICharacterPetBuffService, ICountByKeyAction<long>, IPersistAction<CharacterPetBuffData, long>, IPersistManyAction<CharacterPetBuffData>, IDeleteByKeyVersionedAction<long>, IFetchCollectionByKeyAction<long, CharacterPetBuffData>
Inheritance
CharacterPetBuffService
Implements
Inherited Members

Remarks

Every DTO field maps to the column of the same name, and every column is written. This used to be a renaming layer: Level into stacks, BuffTimeEnd into remaining_time, with tick_time and tick_count hard-coded to zero as "reserved for future use". They were never reserved. They are the tick schedule and the accumulated tick count of a periodic effect, the player's own buff service has always written them, and zeroing them restored a damage-over-time effect on a pet with its cumulative progress erased and its next tick due immediately.

Constructors

CharacterPetBuffService(INpgsqlDbContextFactory)

Initializes a new instance of the CharacterPetBuffService class.

public CharacterPetBuffService(INpgsqlDbContextFactory dbContextFactory)

Parameters

dbContextFactory INpgsqlDbContextFactory

Factory for creating database contexts.

Exceptions

ArgumentNullException

Thrown when dbContextFactory is null.

Methods

CountAsync(long, CancellationToken)

Counts items for the given key.

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

Parameters

characterId long
cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult<int>>

DeleteAsync(long, long, CancellationToken)

Deletes the entity identified by the given key if incomingVersion is newer.

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

Parameters

characterId long
incomingVersion long

The authoritative, monotonic version for this delete operation.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult>

FetchAsync(long, CancellationToken)

Fetches a collection of items for the given key.

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

Parameters

characterId long
cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult<IReadOnlyList<CharacterPetBuffData>>>

PersistAsync(CharacterPetBuffData, CancellationToken)

Persists the provided data.

public Task<DatabaseResult<long>> PersistAsync(CharacterPetBuffData buffData, CancellationToken cancellationToken = default)

Parameters

buffData CharacterPetBuffData
cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult<long>>

PersistAsync(IEnumerable<CharacterPetBuffData>, CancellationToken)

Persists the provided items.

public Task<DatabaseResult<BulkWriteResult>> PersistAsync(IEnumerable<CharacterPetBuffData> buffs, CancellationToken cancellationToken = default)

Parameters

buffs IEnumerable<CharacterPetBuffData>
cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult<BulkWriteResult>>

What the write actually did, or a failure.

Remarks

A successful result does not mean every supplied row was written. Batched writes are version-gated and the service filters what it cannot act on, so the outcome carries counts rather than a bare boolean — see BulkWriteResult, which explains which discrepancies a caller should care about and which are routine.