docs(store): expand package examples for workspace flow
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
0accc6e85e
commit
69cf03e69d
2 changed files with 34 additions and 4 deletions
33
doc.go
33
doc.go
|
|
@ -1,5 +1,6 @@
|
|||
// Package store provides SQLite-backed storage for grouped entries, TTL expiry,
|
||||
// namespace isolation, quota enforcement, and reactive change notifications.
|
||||
// namespace isolation, quota enforcement, reactive change notifications, and
|
||||
// workspace journalling.
|
||||
//
|
||||
// Usage example:
|
||||
//
|
||||
|
|
@ -61,5 +62,35 @@
|
|||
// }
|
||||
// fmt.Println(groupName)
|
||||
// }
|
||||
//
|
||||
// workspace, err := storeInstance.NewWorkspace("scroll-session")
|
||||
// if err != nil {
|
||||
// return
|
||||
// }
|
||||
// defer workspace.Discard()
|
||||
//
|
||||
// if err := workspace.Put("like", map[string]any{"user": "@alice"}); err != nil {
|
||||
// return
|
||||
// }
|
||||
// if err := workspace.Put("profile_match", map[string]any{"user": "@charlie"}); err != nil {
|
||||
// return
|
||||
// }
|
||||
// if result := workspace.Commit(); !result.OK {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// journalResult := storeInstance.QueryJournal(`from(bucket: "events") |> range(start: -24h)`)
|
||||
// if !journalResult.OK {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// archiveResult := storeInstance.Compact(store.CompactOptions{
|
||||
// Before: time.Now().Add(-30 * 24 * time.Hour),
|
||||
// Output: "/tmp/archive",
|
||||
// Format: "gzip",
|
||||
// })
|
||||
// if !archiveResult.OK {
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
package store
|
||||
|
|
|
|||
|
|
@ -32,8 +32,7 @@ FROM workspace_entries`
|
|||
|
||||
var defaultWorkspaceStateDirectory = ".core/state"
|
||||
|
||||
// Workspace accumulates mutable work-in-progress entries before they are
|
||||
// committed to the durable store journal.
|
||||
// Workspace is a temporary SQLite buffer for a named unit of work.
|
||||
// Usage example: `workspace, err := storeInstance.NewWorkspace("scroll-session-2026-03-30"); if err != nil { return }; defer workspace.Discard()`
|
||||
type Workspace struct {
|
||||
name string
|
||||
|
|
@ -46,7 +45,7 @@ type Workspace struct {
|
|||
closed bool
|
||||
}
|
||||
|
||||
// NewWorkspace creates a workspace state file under `.core/state/`.
|
||||
// NewWorkspace creates a temporary SQLite state file under `.core/state/`.
|
||||
// Usage example: `workspace, err := storeInstance.NewWorkspace("scroll-session-2026-03-30")`
|
||||
func (storeInstance *Store) NewWorkspace(name string) (*Workspace, error) {
|
||||
validation := core.ValidateName(name)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue