// Package sync supports the delta-sync endpoint by writing an // append-only library_changes log alongside every mutation on tracked // entities (artists, albums, tracks, likes, playlists, playlist_tracks). // // Callers MUST pass the same transaction that performed the underlying // mutation — the change row and the mutation must commit or roll back // together. See LogChange in changes.go. package sync // EntityType enumerates the entity kinds whose mutations are tracked // by the library_changes log: the shared library, the same for every // listener. The CHECK constraint on library_changes.entity_type also admits // like_* and playlist* values, which older servers wrote and an older backup // may still carry; nothing writes or reads them. type EntityType string const ( EntityArtist EntityType = "artist" EntityAlbum EntityType = "album" EntityTrack EntityType = "track" ) // Op is upsert or delete. Matches the CHECK constraint on library_changes.op. type Op string const ( OpUpsert Op = "upsert" OpDelete Op = "delete" ) // Change is the wire shape returned by the sync endpoint to clients. type Change struct { ID int64 `json:"id"` EntityType EntityType `json:"entity_type"` EntityID string `json:"entity_id"` Op Op `json:"op"` }