AGENT SKILL

buoyient-service

How to create and register new SyncableObjectService implementations using the buoyient offline-first sync library. Use this skill whenever the user wants to add a new data type or service to an app that uses buoyient, create a syncable model, build CRUD operations with offline support, set up background sync for a new entity, or integrate a new API endpoint with buoyient's sync engine. Also trigger when the user mentions SyncableObject, SyncableObjectService, ServerProcessingConfig, or asks about offline-first data patterns in a Kotlin/Android context.

License 许可
Apache-2.0
最近更新
2026-05-23
Stars
★ 4
Forks
0

01 前言 Front Matter

name
buoyient-service
description
How to create and register new SyncableObjectService implementations using the buoyient offline-first sync library. Use this skill whenever the user wants to add a new data type or service to an app that uses buoyient, create a syncable model, build CRUD operations with offline support, set up background sync for a new entity, or integrate a new API endpoint with buoyient's sync engine. Also trigger when the user mentions SyncableObject, SyncableObjectService, ServerProcessingConfig, or asks about offline-first data patterns in a Kotlin/Android context.

03 SKILL.md 正文

Use docs/creating-a-service.md as the authoritative service-building guide, and the project-level context file (CLAUDE.md / CODEX.md) for shared project conventions.

Key points to remember:

  • Data models must be @Serializable data classes implementing SyncableObject<O> with withSyncStatus() and @Transient syncStatus.
  • Services extend SyncableObjectService<O, T> where T : ServiceRequestTag. The constructor takes a KSerializer<O> (not a manual deserializer).
  • Service-level configuration classes (ServerProcessingConfig, SyncFetchConfig, SyncUpConfig, SyncUpResult, ConnectivityChecker, EncryptionProvider, PendingRequestQueueStrategy, SyncableObjectRebaseHandler) are in the com.elvdev.buoyient.serviceconfigs package.
  • Data types used when interacting with SyncableObjectService (HttpRequest, SyncableObjectServiceResponse, SyncableObjectServiceRequestState, GetResponse, CreateRequestBuilder, UpdateRequestBuilder, VoidRequestBuilder, ResponseUnpacker, SquashRequestMerger) are in the com.elvdev.buoyient.datatypes package.
  • Every operation (create, update, void) requires a ServiceRequestTag and uses functional interfaces: CreateRequestBuilder, UpdateRequestBuilder, VoidRequestBuilder, ResponseUnpacker.
  • SyncUpConfig.fromResponseBody(requestTag, responseBody) returns SyncUpResult<O>: Success(data), Failed.Retry (re-queue), or Failed.RemovePendingRequest (drop from queue).
  • ServerProcessingConfig.serviceHeaders provides per-service HTTP headers. For auth headers shared across all services, use Buoyient.globalHeaderProvider (a GlobalHeaderProvider lambda evaluated per-request, in com.elvdev.buoyient.globalconfigs).
  • getAllFromLocalStore(limit) retrieves all items from the local database.
  • LocalStoreManager accepts an optional queueStrategy: Queue (default) stores every operation separately; Squash collapses consecutive offline edits into one request. Use Squash for PUT/replace APIs where intermediate states don't matter. See docs/creating-a-service.md § "Pending request queue strategy".
  • SyncableObject companion constants use _KEY suffix: SERVER_ID_KEY, CLIENT_ID_KEY, VERSION_KEY.

04 同仓库更多 Skills