store

package
v0.19.4 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

The store plugin module, implemented against the plugin SDK (pkg/plugin). The same implementation serves both builds: compiled into the OpenRun binary as "store.in" (registered below as a local provider), and as the out-of-process provider executable in ./storeprovider (loadable as "store.ex", or "store.in" in a binary without the compiled-in module).

Index

Constants

View Source
const (
	AND_CONDITION = "$AND"
	OR_CONDITION  = "$OR"
)
View Source
const (
	SELECT_MAX_LIMIT     = 100_000
	SELECT_DEFAULT_LIMIT = 10_000
	SORT_ASCENDING       = "asc"
	SORT_DESCENDING      = "desc"
	MAX_TABLE_NAME_LEN   = 63
)
View Source
const (
	ID_FIELD         = "_id"
	VERSION_FIELD    = "_version"
	CREATED_BY_FIELD = "_created_by"
	UPDATED_BY_FIELD = "_updated_by"
	CREATED_AT_FIELD = "_created_at"
	UPDATED_AT_FIELD = "_updated_at"
	JSON_FIELD       = "_json"
)
View Source
const TRANSACTION_KEY = "transaction"

Variables

Functions

func NewStoreModule added in v0.19.0

func NewStoreModule() plugin.Module

func ProviderConfig added in v0.19.0

func ProviderConfig(version string) *plugin.ServeConfig

ProviderConfig returns the store plugin's provider config, shared by the compiled-in registration above and the storeprovider executable.

Types

type Document

type Document map[string]any

type Entry

type Entry struct {
	Id        EntryId
	Version   int64
	CreatedBy UserId
	UpdatedBy UserId
	CreatedAt time.Time
	UpdatedAt time.Time
	Data      Document
}

type EntryId

type EntryId int64

type EntryIterator added in v0.19.0

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

EntryIterator lazily iterates the rows of a select, converting each row to an Entry. It is starlark-free so the external store provider can stream results through it.

func (*EntryIterator) Close added in v0.19.0

func (it *EntryIterator) Close() error

Close releases the underlying cursor. Safe to call after exhaustion.

func (*EntryIterator) LeakKey added in v0.19.0

func (it *EntryIterator) LeakKey() string

LeakKey names the strict deferred-cleanup entry registered for this iterator: if the app never consumes or closes the cursor, the request fails citing this key.

func (*EntryIterator) Next added in v0.19.0

func (it *EntryIterator) Next() (*Entry, bool, error)

Next returns the next entry, or ok=false when the rows are exhausted (the underlying cursor is closed implicitly then). A scan error closes the cursor and is returned.

func (*EntryIterator) Table added in v0.19.0

func (it *EntryIterator) Table() string

Table returns the physical table name the iterator reads from.

type SqlStore

type SqlStore struct {
	*types.Logger
	sync.Mutex
	// contains filtered or unexported fields
}

func NewSqlStore

func NewSqlStore(pluginContext *types.PluginContext) (*SqlStore, error)

func (*SqlStore) Begin

func (s *SqlStore) Begin(ctx context.Context) (*sql.Tx, error)

func (*SqlStore) Close added in v0.19.2

func (s *SqlStore) Close() error

Close releases the store's database connection pool. A store module owns exactly one SqlStore, so its module Close callback is the lifecycle boundary for both the in-process and out-of-process plugin builds.

func (*SqlStore) Commit

func (s *SqlStore) Commit(ctx context.Context, tx *sql.Tx) error

func (*SqlStore) Count

func (s *SqlStore) Count(ctx context.Context, tx *sql.Tx, table string, filter map[string]any) (int64, error)

Count returns the number of entries matching the filter

func (*SqlStore) Delete

func (s *SqlStore) Delete(ctx context.Context, tx *sql.Tx, table string, filter map[string]any) (int64, error)

Delete entries from the store matching the filter

func (*SqlStore) DeleteById

func (s *SqlStore) DeleteById(ctx context.Context, tx *sql.Tx, table string, id EntryId) (int64, error)

DeleteById an entry from the store by id

func (*SqlStore) Insert

func (s *SqlStore) Insert(ctx context.Context, tx *sql.Tx, table string, entry *Entry) (EntryId, error)

Insert a new entry in the store

func (*SqlStore) Rollback

func (s *SqlStore) Rollback(ctx context.Context, tx *sql.Tx) error

func (*SqlStore) SelectById

func (s *SqlStore) SelectById(ctx context.Context, tx *sql.Tx, table string, id EntryId) (*Entry, error)

SelectById returns a single item from the store

func (*SqlStore) SelectEntries added in v0.19.0

func (s *SqlStore) SelectEntries(ctx context.Context, tx *sql.Tx, table string, filter map[string]any, sort []string, offset, limit int64) (*EntryIterator, error)

SelectEntries runs a select and returns a Go-level lazy iterator over the matching entries. The caller owns closing the iterator (or fully draining it, which closes it implicitly).

func (*SqlStore) SelectOne

func (s *SqlStore) SelectOne(ctx context.Context, tx *sql.Tx, table string, filter map[string]any) (*Entry, error)

SelectOne returns a single item from the store

func (*SqlStore) Update

func (s *SqlStore) Update(ctx context.Context, tx *sql.Tx, table string, entry *Entry) (int64, error)

Update an existing entry in the store

type UserId

type UserId string

Directories

Path Synopsis
Command storeprovider is the out-of-process provider build of the store plugin: the same module implementation that is compiled into OpenRun as "store.in" (internal/app/store), served as an external provider.
Command storeprovider is the out-of-process provider build of the store plugin: the same module implementation that is compiled into OpenRun as "store.in" (internal/app/store), served as an external provider.

Jump to

Keyboard shortcuts

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