Refactor API response descriptors to use resource classes
- Updated response descriptors in various endpoints to utilize specific resource classes instead of generic JsonResponse. - Changed response types for friendship, guild, party, and support issue endpoints to their respective resource classes. - Incremented version number in manifest.json to 0.5.3 for the new changes.
This commit is contained in:
@@ -72,6 +72,19 @@ CompletableFuture<ServerProfile> profile =
|
||||
cache.forcePull(serverProfileCall, CacheContext.shared());
|
||||
```
|
||||
|
||||
Invalidate a cached value:
|
||||
|
||||
```java
|
||||
cache.invalidate(serverProfileCall, CacheContext.shared());
|
||||
```
|
||||
|
||||
Prewarm after an event-driven invalidation:
|
||||
|
||||
```java
|
||||
CompletableFuture<ServerProfile> profile =
|
||||
cache.prewarm(serverProfileCall, CacheContext.shared());
|
||||
```
|
||||
|
||||
## Player Storage
|
||||
|
||||
Player storage requires explicit context. Core-network does not infer player identity from the API URI.
|
||||
@@ -94,6 +107,36 @@ CompletableFuture<PlayerSessionProfile> profile =
|
||||
|
||||
`NetworkPlugin.setup()` registers `NetworkApiDataComponent` with the entity store registry.
|
||||
|
||||
## Reactive Player Hooks
|
||||
|
||||
`ReactivePlayerCacheHooks` gives ECS/event systems a small public surface for cache invalidation and prewarming when control-plane state changes.
|
||||
|
||||
Entry point:
|
||||
|
||||
```java
|
||||
ReactivePlayerCacheHooks hooks =
|
||||
NetworkPlugin.client().reactivePlayerCache();
|
||||
```
|
||||
|
||||
Use it from player lifecycle or control-plane event handlers:
|
||||
|
||||
```java
|
||||
PlayerCacheContext context = new PlayerCacheContext(playerId, playerRef, entityStore);
|
||||
|
||||
hooks.onPlayerJoin(context);
|
||||
hooks.onPermissionChanged(context);
|
||||
hooks.onSanctionChanged(context);
|
||||
hooks.onNotificationCreated(context);
|
||||
```
|
||||
|
||||
The hook currently covers:
|
||||
|
||||
- `players/{player}/moderation/sanction-snapshot`
|
||||
- `players/{player}/authorization/permission-snapshot`
|
||||
- `players/{player}/notifications`
|
||||
|
||||
`onPlayerJoin(...)` force-refreshes sanction and permission snapshots and prewarms notifications. The change-specific hooks invalidate the stale player entry and immediately pull the new value.
|
||||
|
||||
## Freshness Policies
|
||||
|
||||
Auto-refresh when older than max age:
|
||||
@@ -190,6 +233,11 @@ public final class MyAssetCacheAdapter implements AssetStoreCacheAdapter {
|
||||
public void write(ApiCacheKey key, ApiCacheEntry entry, CacheContext context) {
|
||||
// Convert entry payload into concrete asset and load/write through AssetStore.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(ApiCacheKey key, CacheContext context) {
|
||||
// Remove or mark the mapped asset entry stale when invalidated.
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -207,6 +255,13 @@ CachedApiCall<JsonObject> call = CachedApiCall
|
||||
.build();
|
||||
```
|
||||
|
||||
The assets domain now exposes typed generated methods that can feed asset-store-backed cache calls, including:
|
||||
|
||||
```java
|
||||
NetworkPlugin.client().assets().getActivePack(packKey);
|
||||
NetworkPlugin.client().assets().getPackVersionFiles(versionId);
|
||||
```
|
||||
|
||||
## Batching Behavior
|
||||
|
||||
When `ControlPlaneClient.batchingEnabled()` is true, cache pulls and pushes use `BatchClient`.
|
||||
|
||||
@@ -14,6 +14,7 @@ client.presence(); // PresenceClient
|
||||
client.players(); // PlayersClient
|
||||
client.batch(); // BatchClient
|
||||
client.cache(); // ApiDataCacheClient
|
||||
client.reactivePlayerCache(); // ReactivePlayerCacheHooks
|
||||
```
|
||||
|
||||
## Handwritten Domain Clients
|
||||
@@ -35,10 +36,32 @@ client.presence().shutdown(instanceId, "restart");
|
||||
`PlayersClient`
|
||||
|
||||
```java
|
||||
PlayerSessionProfile profile = client.players().getSessionProfile(playerId);
|
||||
List<PlayerEntitlement> entitlements = client.players().getEntitlements(playerId);
|
||||
PlayerSessionProfile profile = client.players().sessionProfile(playerId);
|
||||
List<PlayerEntitlement> entitlements = client.players().entitlementsIndex(playerId);
|
||||
```
|
||||
|
||||
`AssetsClient`
|
||||
|
||||
```java
|
||||
AssetPackVersion active = client.assets().getActivePack(packKey);
|
||||
List<AssetPackVersionFile> files = client.assets().getPackVersionFiles(active.id());
|
||||
```
|
||||
|
||||
## Reactive Player Cache
|
||||
|
||||
`reactivePlayerCache()` is intended for Hytale ECS/event handlers that know player state changed and need cache freshness now, not after a TTL expires.
|
||||
|
||||
```java
|
||||
PlayerCacheContext context = new PlayerCacheContext(playerId, playerRef, entityStore);
|
||||
|
||||
client.reactivePlayerCache().onPlayerJoin(context);
|
||||
client.reactivePlayerCache().onPermissionChanged(context);
|
||||
client.reactivePlayerCache().onSanctionChanged(context);
|
||||
client.reactivePlayerCache().onNotificationCreated(context);
|
||||
```
|
||||
|
||||
These hooks invalidate and prewarm the player-scoped cache entries for permission snapshots, moderation sanction snapshots, and notifications.
|
||||
|
||||
## Error Handling
|
||||
|
||||
Transport errors use checked `ControlPlaneException` subclasses:
|
||||
|
||||
@@ -17,6 +17,7 @@ These files include:
|
||||
- middleware metadata
|
||||
- request field descriptors
|
||||
- response type descriptors
|
||||
- typed domain clients and DTOs for generated API resources
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -44,6 +45,18 @@ String uri = PathBuilder.resolve(
|
||||
);
|
||||
```
|
||||
|
||||
Use generated domain clients for direct typed calls:
|
||||
|
||||
```java
|
||||
PlayerPermissionSnapshot permissions =
|
||||
NetworkPlugin.client().players().authorizationPermissionSnapshot(playerId);
|
||||
|
||||
AssetPackVersion activePack =
|
||||
NetworkPlugin.client().assets().getActivePack(packKey);
|
||||
```
|
||||
|
||||
Some generated clients include hand-friendly aliases for route-shaped names. For example, the assets domain exposes `getActivePack(...)` and `getPackVersionFiles(...)` over the generated active-pack and version-files endpoints.
|
||||
|
||||
## Regeneration
|
||||
|
||||
The source of truth is `../core-control-plane`.
|
||||
|
||||
@@ -9,6 +9,7 @@ It provides:
|
||||
- generated API endpoint descriptors from `core-control-plane`
|
||||
- batched HTTP calls through `/api/v1/batch`
|
||||
- API response storage policies for runtime, player, and asset-store-backed data
|
||||
- reactive player cache hooks for ECS/event-driven invalidation and prewarming
|
||||
|
||||
## Pages
|
||||
|
||||
@@ -40,3 +41,4 @@ net.kewwbec.network
|
||||
- Treat `core-control-plane` as the API owner.
|
||||
- Use batching for repeated or concurrent calls that can tolerate async completion.
|
||||
- Use cache policies when plugin code needs shared ownership of API freshness or push timing.
|
||||
- Use `reactivePlayerCache()` from ECS/event handlers when player cache state must react immediately to permission, sanction, notification, or join events.
|
||||
|
||||
Reference in New Issue
Block a user