Class GrpcSnapshotService
- All Implemented Interfaces:
SnapshotService
- Since:
- 1.0.0-SNAPSHOT
- Version:
- 1.0
- Author:
- Jimmy (vSKAH) - 17/04/2026
-
Field Summary
Fields inherited from class AbstractGrpcService
grpcClientManager, tachyonMetrics -
Constructor Summary
ConstructorsConstructorDescriptionGrpcSnapshotService(@Nullable TachyonMetrics tachyonMetrics, GrpcClientManager grpcClientManager) -
Method Summary
Modifier and TypeMethodDescriptiondecodeSnapshot(@NotNull String snapshotId) Fetches and decodes the actual data payload of a specific snapshot from the backend.getSnapshots(@NotNull String playerUniqueId) Retrieves the metadata history of all snapshots associated with a specific player.protected <T> voidhandleGrpcExceptions(String actionName, tech.skworks.tachyon.libs.io.grpc.StatusRuntimeException ex, CompletableFuture<T> future) voidshutdown()<T extends tech.skworks.tachyon.libs.com.google.protobuf.Message>
CompletableFuture<Void> takeComponentSnapshot(@NotNull String playerUniqueId, @NotNull String reason, @NotNull SnapshotTriggerType triggerType, T component) Triggers an asynchronous backup of a single, specific Protobuf component for a player.takeDatabaseSnapshot(@NotNull String playerUniqueId, @NotNull String reason, @NotNull SnapshotTriggerType triggerType) Triggers an asynchronous backup of a player's entire profile based on the current database state.toggleSnapshotLocking(@NotNull String snapshotId, @NotNull String executorUniqueId) Asynchronously toggles the lock status of a specific snapshot.Methods inherited from class AbstractGrpcService
asyncCall, asyncRun, recordError, recordError, startTimer
-
Constructor Details
-
GrpcSnapshotService
public GrpcSnapshotService(@Nullable @Nullable TachyonMetrics tachyonMetrics, GrpcClientManager grpcClientManager)
-
-
Method Details
-
handleGrpcExceptions
protected <T> void handleGrpcExceptions(String actionName, tech.skworks.tachyon.libs.io.grpc.StatusRuntimeException ex, CompletableFuture<T> future) - Specified by:
handleGrpcExceptionsin classAbstractGrpcService
-
takeDatabaseSnapshot
public CompletableFuture<Void> takeDatabaseSnapshot(@NotNull @NotNull String playerUniqueId, @NotNull @NotNull String reason, @NotNull @NotNull SnapshotTriggerType triggerType) Description copied from interface:SnapshotServiceTriggers an asynchronous backup of a player's entire profile based on the current database state.Important Warning: This method snapshots the data exactly as it currently exists in the backend database, not the live data present in the Spigot server's memory. If the player has "dirty" components that have not yet been flushed to the backend (via
saveProfile()orsaveComponent()), those unsaved changes will not be included in this snapshot.This creates a snapshot with
FULLgranularity. Because it serializes every piece of data currently attached to the player's database document, it should be used for major events (e.g., player bans, manual admin backups, or major scheduled saves).- Specified by:
takeDatabaseSnapshotin interfaceSnapshotService- Parameters:
playerUniqueId- The UUID of the player whose profile is being snapshotted.reason- The human-readable reason for this snapshot (e.g., "Suspected duplication").triggerType- The system or user action that triggered this backup (e.g., MANUAL, SPIGOT_TASK).- Returns:
- A CompletableFuture that completes when the backend has successfully saved the full snapshot.
-
takeComponentSnapshot
public <T extends tech.skworks.tachyon.libs.com.google.protobuf.Message> CompletableFuture<Void> takeComponentSnapshot(@NotNull @NotNull String playerUniqueId, @NotNull @NotNull String reason, @NotNull @NotNull SnapshotTriggerType triggerType, @NotNull T component) Description copied from interface:SnapshotServiceTriggers an asynchronous backup of a single, specific Protobuf component for a player.This creates a snapshot with
SPECIFIC_COMPONENTgranularity in the database. It is highly optimized, sending only the compressed raw bytes (Zstd) of the targeted component over the network. Ideal for frequent, highly targeted backups (e.g., saving an inventory right after a trade).- Specified by:
takeComponentSnapshotin interfaceSnapshotService- Type Parameters:
T- The specific type of the Protobuf message.- Parameters:
playerUniqueId- The UUID of the player associated with the data.reason- The human-readable reason for this specific snapshot.triggerType- The system or user action that triggered this backup.component- The specific Protobuf message instance containing the data to backup.- Returns:
- A CompletableFuture that completes when the backend has successfully saved the specific snapshot.
-
toggleSnapshotLocking
public CompletableFuture<ToggleLockSnapshotResponse> toggleSnapshotLocking(@NotNull @NotNull String snapshotId, @NotNull @NotNull String executorUniqueId) Description copied from interface:SnapshotServiceAsynchronously toggles the lock status of a specific snapshot.A locked snapshot is protected from being automatically purged or archived by scheduled maintenance tasks (such as the S3 Archiver job). This method inverses the current lock state (locks an unlocked snapshot, or unlocks a locked one).
- Specified by:
toggleSnapshotLockingin interfaceSnapshotService- Parameters:
snapshotId- The unique identifier (ObjectId hex string) of the target snapshot. Must not be null.executorUniqueId- The unique identifier (e.g., UUID) of the administrator or system executing this action. Must not be null.- Returns:
- A
CompletableFuturethat, when successfully completed, yields aToggleLockSnapshotResponsecontaining the newly applied lock status.
-
getSnapshots
public CompletableFuture<ListSnapshotsResponse> getSnapshots(@NotNull @NotNull String playerUniqueId) Description copied from interface:SnapshotServiceRetrieves the metadata history of all snapshots associated with a specific player.This method does not download the actual heavy data payloads. It only fetches the lightweight metadata (IDs, timestamps, reasons, granularity) used to populate the administrative Snapshot GUI lists.
- Specified by:
getSnapshotsin interfaceSnapshotService- Parameters:
playerUniqueId- The UUID of the player whose snapshot history is being requested.- Returns:
- A CompletableFuture containing the response with the list of snapshot metadata.
-
decodeSnapshot
public CompletableFuture<DecodeSnapshotResponse> decodeSnapshot(@NotNull @NotNull String snapshotId) Description copied from interface:SnapshotServiceFetches and decodes the actual data payload of a specific snapshot from the backend.Whether the snapshot is
FULL(JSON parsed) orSPECIFIC_COMPONENT(Raw Binary), the backend will process it and return a standardized response containing the decoded Protobuf components wrapped inAnyobjects, ready to be processed by theComponentRegistry.- Specified by:
decodeSnapshotin interfaceSnapshotService- Parameters:
snapshotId- The unique MongoDB ObjectId string of the snapshot to retrieve.- Returns:
- A CompletableFuture containing the decoded snapshot data payload.
-
shutdown
public void shutdown()
-