state

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const CursorSchema = `` /* 305-byte string literal not displayed */
View Source
const Schema = `` /* 317-byte string literal not displayed */
View Source
const ScopedSchema = `` /* 206-byte string literal not displayed */

Variables

This section is empty.

Functions

func EnsureCursorSchema

func EnsureCursorSchema(ctx context.Context, db execQuerier) error

func EnsureSchema

func EnsureSchema(ctx context.Context, db execQuerier) error

func EnsureScopedSchema

func EnsureScopedSchema(ctx context.Context, db execQuerier) error

func ManifestKey

func ManifestKey(sourceName string) (string, string, string)

Types

type CursorRecord

type CursorRecord struct {
	Source     string    `json:"source"`
	EntityType string    `json:"entity_type"`
	EntityID   string    `json:"entity_id"`
	Cursor     string    `json:"cursor"`
	SyncedAt   time.Time `json:"synced_at"`
}

type CursorStore

type CursorStore struct {
	// contains filtered or unexported fields
}

func NewCursor

func NewCursor(db execQuerier) *CursorStore

func NewCursorWithClock

func NewCursorWithClock(db execQuerier, now func() time.Time) *CursorStore

func (*CursorStore) Get

func (s *CursorStore) Get(ctx context.Context, source, entityType, entityID string) (CursorRecord, bool, error)

func (*CursorStore) IsStale

func (s *CursorStore) IsStale(ctx context.Context, source, entityType, entityID string, maxAge time.Duration) (bool, error)

func (*CursorStore) Set

func (s *CursorStore) Set(ctx context.Context, source, entityType, entityID, cursor string) error

type Record

type Record struct {
	SourceName string    `json:"source_name"`
	EntityType string    `json:"entity_type"`
	EntityID   string    `json:"entity_id"`
	Value      string    `json:"value"`
	UpdatedAt  time.Time `json:"updated_at"`
}

type ScopedRecord

type ScopedRecord struct {
	Scope     string    `json:"scope"`
	Cursor    string    `json:"cursor"`
	UpdatedAt time.Time `json:"updated_at"`
}

type ScopedStore

type ScopedStore struct {
	// contains filtered or unexported fields
}

func NewScoped

func NewScoped(db execQuerier) *ScopedStore

func NewScopedWithClock

func NewScopedWithClock(db execQuerier, now func() time.Time) *ScopedStore

func (*ScopedStore) Get

func (s *ScopedStore) Get(ctx context.Context, scope string) (ScopedRecord, bool, error)

func (*ScopedStore) IsStale

func (s *ScopedStore) IsStale(ctx context.Context, scope string, maxAge time.Duration) (bool, error)

func (*ScopedStore) Set

func (s *ScopedStore) Set(ctx context.Context, scope, cursor string) error

type Store

type Store struct {
	// contains filtered or unexported fields
}

func New

func New(db execQuerier) *Store

func NewWithClock

func NewWithClock(db execQuerier, now func() time.Time) *Store

func (*Store) Get

func (s *Store) Get(ctx context.Context, sourceName, entityType, entityID string) (Record, bool, error)

func (*Store) IsStale

func (s *Store) IsStale(ctx context.Context, sourceName, entityType, entityID string, maxAge time.Duration) (bool, error)

func (*Store) Set

func (s *Store) Set(ctx context.Context, sourceName, entityType, entityID, value string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL