Documentation
¶
Overview ¶
Package remote implements the cloud-backed sync transport for Engram.
It provides a Transport implementation that communicates with the Engram Cloud server for push/pull sync operations over HTTP.
Package remote implements the cloud-backed sync transport for Engram.
It provides a Transport implementation that communicates with the Engram Cloud server for push/pull sync operations over HTTP.
Index ¶
- type MutationEntry
- type PullMutationResult
- type PullMutationsResponse
- type PushMutationsResult
- type RemoteTransport
- func (rt *RemoteTransport) PullMutations(sinceSeq int64, limit int) (*PullMutationsResponse, error)
- func (rt *RemoteTransport) PushMutations(mutations []MutationEntry) (*PushMutationsResult, error)
- func (rt *RemoteTransport) ReadChunk(chunkID string) ([]byte, error)
- func (rt *RemoteTransport) ReadManifest() (*engramsync.Manifest, error)
- func (rt *RemoteTransport) SetTokenRefresher(refreshToken string, onTokenRefresh func(string) error)
- func (rt *RemoteTransport) WriteChunk(chunkID string, data []byte, entry engramsync.ChunkEntry) error
- func (rt *RemoteTransport) WriteManifest(_ *engramsync.Manifest) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MutationEntry ¶
type MutationEntry struct {
Entity string `json:"entity"`
EntityKey string `json:"entity_key"`
Op string `json:"op"`
Payload json.RawMessage `json:"payload"`
}
MutationEntry represents a single mutation for push/pull operations.
type PullMutationResult ¶
type PullMutationResult struct {
Seq int64 `json:"seq"`
Entity string `json:"entity"`
EntityKey string `json:"entity_key"`
Op string `json:"op"`
Payload json.RawMessage `json:"payload"`
OccurredAt string `json:"occurred_at"`
}
PullMutationResult represents a single mutation returned by the server.
type PullMutationsResponse ¶
type PullMutationsResponse struct {
Mutations []PullMutationResult `json:"mutations"`
HasMore bool `json:"has_more"`
}
PullMutationsResult holds the server response for a mutation pull.
type PushMutationsResult ¶
PushMutationsResult holds the server response for a mutation push.
type RemoteTransport ¶
type RemoteTransport struct {
// contains filtered or unexported fields
}
RemoteTransport pushes/pulls chunks over HTTP to an Engram cloud server. It implements sync.Transport.
func NewRemoteTransport ¶
func NewRemoteTransport(baseURL, token string) (*RemoteTransport, error)
func (*RemoteTransport) PullMutations ¶
func (rt *RemoteTransport) PullMutations(sinceSeq int64, limit int) (*PullMutationsResponse, error)
PullMutations fetches mutations from the cloud server since a given sequence. GET /sync/mutations/pull?since_seq=N&limit=M
func (*RemoteTransport) PushMutations ¶
func (rt *RemoteTransport) PushMutations(mutations []MutationEntry) (*PushMutationsResult, error)
PushMutations sends a batch of mutations to the cloud server. POST /sync/mutations/push
func (*RemoteTransport) ReadChunk ¶
func (rt *RemoteTransport) ReadChunk(chunkID string) ([]byte, error)
ReadChunk downloads a specific chunk from the cloud server. GET /sync/pull/{chunk_id} returns the raw stored push body. This method extracts the data field and converts it back to ChunkData JSON.
func (*RemoteTransport) ReadManifest ¶
func (rt *RemoteTransport) ReadManifest() (*engramsync.Manifest, error)
ReadManifest fetches the chunk manifest from the cloud server. GET /sync/pull returns {"version": 1, "chunks": [...]}.
func (*RemoteTransport) SetTokenRefresher ¶
func (rt *RemoteTransport) SetTokenRefresher(refreshToken string, onTokenRefresh func(string) error)
SetTokenRefresher configures optional access-token refresh for sync operations.
func (*RemoteTransport) WriteChunk ¶
func (rt *RemoteTransport) WriteChunk(chunkID string, data []byte, entry engramsync.ChunkEntry) error
WriteChunk pushes a chunk to the cloud server via POST /sync/push. The data parameter is raw ChunkData JSON; this method wraps it in the push request format the server expects.
func (*RemoteTransport) WriteManifest ¶
func (rt *RemoteTransport) WriteManifest(_ *engramsync.Manifest) error
WriteManifest is a no-op for remote: the cloud server manages its own manifest.