oplog

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStopIteration = errors.New("stop iteration")
	ErrNotExist      = errors.New("operation does not exist")
	ErrExist         = errors.New("operation already exists")
	ErrNoResults     = errors.New("no results found")

	NullOPID = int64(0)
)
View Source
var CurrentVersion = int64(len(migrations))
View Source
var SelectAll = Query{}

Functions

func ApplyMigrations added in v1.0.0

func ApplyMigrations(oplog *OpLog) error

Types

type OpLog

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

func NewOpLog

func NewOpLog(store OpStore) (*OpLog, error)

func (*OpLog) Add

func (o *OpLog) Add(ops ...*v1.Operation) error

func (*OpLog) Delete

func (o *OpLog) Delete(opID ...int64) error

func (*OpLog) FindOne added in v1.11.0

func (o *OpLog) FindOne(q Query) (*v1.Operation, error)

func (*OpLog) FindOneMetadata added in v1.11.0

func (o *OpLog) FindOneMetadata(q Query) (OpMetadata, error)

func (*OpLog) Get

func (o *OpLog) Get(opID int64) (*v1.Operation, error)

func (*OpLog) GetHighestOpIDAndModno added in v1.11.0

func (o *OpLog) GetHighestOpIDAndModno(q Query) (int64, int64, error)

func (*OpLog) Query added in v1.5.0

func (o *OpLog) Query(q Query, f func(*v1.Operation) error) error

func (*OpLog) QueryMetadata added in v1.7.0

func (o *OpLog) QueryMetadata(q Query, f func(OpMetadata) error) error

func (*OpLog) Set added in v1.7.0

func (o *OpLog) Set(opts SetOptions, ops ...*v1.Operation) error

func (*OpLog) Subscribe

func (o *OpLog) Subscribe(q Query, f *Subscription)

func (*OpLog) Transform added in v1.5.0

func (o *OpLog) Transform(q Query, f func(*v1.Operation) (*v1.Operation, error)) error

func (*OpLog) Unsubscribe

func (o *OpLog) Unsubscribe(f *Subscription) error

func (*OpLog) Update

func (o *OpLog) Update(ops ...*v1.Operation) error

type OpMetadata added in v1.7.0

type OpMetadata struct {
	ID             int64
	FlowID         int64
	Modno          int64
	OriginalID     int64
	OriginalFlowID int64
	Status         v1.OperationStatus
	RepoID         string
	RepoGUID       string
	PlanID         string
}

OpMetadata is a struct that contains metadata about an operation without fetching the operation itself.

type OpStore added in v1.5.0

type OpStore interface {
	// Query returns all operations that match the query.
	Query(q Query, f func(*v1.Operation) error) error
	// QueryMetadata is like Query, but only returns metadata about the operations.
	// this is useful for very high performance scans that don't deserialize the operation itself.
	QueryMetadata(q Query, f func(OpMetadata) error) error
	// Get returns the operation with the given ID.
	Get(opID int64) (*v1.Operation, error)
	// GetHighestOpIDAndModno returns the highest operation ID and modno in the store, used for synchronization.
	GetHighestOpIDAndModno(q Query) (int64, int64, error)
	// Add adds the given operations to the store.
	Add(op ...*v1.Operation) error
	// Update updates the given operations in the store.
	Update(op ...*v1.Operation) error
	// Set inserts or updates operations. Zero-valued fields (Id, Modno, FlowId) are
	// allocated automatically (like Add/Update), but non-zero values provided by the
	// caller are preserved. If Id is non-zero, it updates; if Id is zero, it inserts.
	Set(opts SetOptions, op ...*v1.Operation) error
	// Delete removes the operations with the given IDs from the store, and returns the removed operations.
	Delete(opID ...int64) ([]*v1.Operation, error)
	// Transform applies the given function to each operation that matches the query.
	Transform(q Query, f func(*v1.Operation) (*v1.Operation, error)) error
	// Version returns the current data version
	Version() (int64, error)
	// SetVersion sets the data version
	SetVersion(version int64) error
}

type OperationEvent added in v1.5.0

type OperationEvent int
const (
	OPERATION_ADDED OperationEvent = iota
	OPERATION_UPDATED
	OPERATION_DELETED
)

type Query added in v1.0.0

type Query struct {
	// Filter by fields
	OpIDs                 []int64
	PlanID                *string
	RepoGUID              *string
	DeprecatedRepoID      *string // Deprecated: use RepoGUID instead
	SnapshotID            *string
	FlowID                *int64
	InstanceID            *string
	OriginalInstanceKeyid *string
	OriginalID            *int64
	OriginalFlowID        *int64
	ModnoGte              *int64

	// Pagination
	Limit    int
	Offset   int
	Reversed bool
	// contains filtered or unexported fields
}

func (*Query) Match added in v1.5.0

func (q *Query) Match(op *v1.Operation) bool

func (Query) SetFlowID added in v1.7.0

func (q Query) SetFlowID(flowID int64) Query

func (Query) SetInstanceID added in v1.7.0

func (q Query) SetInstanceID(instanceID string) Query

func (Query) SetLimit added in v1.7.0

func (q Query) SetLimit(limit int) Query

func (Query) SetModnoGte added in v1.11.0

func (q Query) SetModnoGte(modnoGte int64) Query

func (Query) SetOffset added in v1.7.0

func (q Query) SetOffset(offset int) Query

func (Query) SetOpIDs added in v1.7.0

func (q Query) SetOpIDs(opIDs []int64) Query

func (Query) SetOriginalFlowID added in v1.7.0

func (q Query) SetOriginalFlowID(originalFlowID int64) Query

func (Query) SetOriginalID added in v1.7.0

func (q Query) SetOriginalID(originalID int64) Query

func (Query) SetOriginalInstanceKeyid added in v1.9.0

func (q Query) SetOriginalInstanceKeyid(instanceKeyid string) Query

func (Query) SetPlanID added in v1.7.0

func (q Query) SetPlanID(planID string) Query

func (Query) SetRepoGUID added in v1.7.0

func (q Query) SetRepoGUID(repoGUID string) Query

func (Query) SetReversed added in v1.7.0

func (q Query) SetReversed(reversed bool) Query

func (Query) SetSnapshotID added in v1.7.0

func (q Query) SetSnapshotID(snapshotID string) Query

type SetOptions added in v1.13.0

type SetOptions struct {
	InsertOnly bool // If true, only insert; fail if the operation already exists (Id != 0).
	UpdateOnly bool // If true, only update; fail if the operation does not exist (Id == 0).
	AllocateID bool // If true, allocate a new Id for operations with Id == 0.
}

SetOptions configures the behavior of Set.

type Subscription added in v1.5.0

type Subscription = func(ops []*v1.Operation, event OperationEvent)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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