crdb

package
v0.0.0-...-860e413 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCopyStatement

func AddCopyStatement(conflict, from, to []handler.Column, conditions []handler.Condition, opts ...execOption) func(eventstore.Event) Exec

func AddCreateStatement

func AddCreateStatement(columns []handler.Column, opts ...execOption) func(eventstore.Event) Exec

func AddDeleteStatement

func AddDeleteStatement(conditions []handler.Condition, opts ...execOption) func(eventstore.Event) Exec

func AddUpdateStatement

func AddUpdateStatement(values []handler.Column, conditions []handler.Condition, opts ...execOption) func(eventstore.Event) Exec

func AddUpsertStatement

func AddUpsertStatement(indexCols []handler.Column, values []handler.Column, opts ...execOption) func(eventstore.Event) Exec

func Hash

func Hash(bucketsCount uint16) indexOpts

func NewArrayAppendCol

func NewArrayAppendCol(column string, value interface{}) handler.Column

func NewArrayIntersectCol

func NewArrayIntersectCol(column string, value interface{}) handler.Column

func NewArrayRemoveCol

func NewArrayRemoveCol(column string, value interface{}) handler.Column

func NewCopyCol

func NewCopyCol(column, from string) handler.Column

func NewCopyStatement

func NewCopyStatement(event eventstore.Event, conflictCols, from, to []handler.Column, conds []handler.Condition, opts ...execOption) *handler.Statement

NewCopyStatement creates a new upsert statement which updates a column from an existing row cols represent the columns which are objective to change. if the value of a col is empty the data will be copied from the selected row if the value of a col is not empty the data will be set by the static value conds represent the conditions for the selection subquery

func NewCreateStatement

func NewCreateStatement(event eventstore.Event, values []handler.Column, opts ...execOption) *handler.Statement

func NewDeleteStatement

func NewDeleteStatement(event eventstore.Event, conditions []handler.Condition, opts ...execOption) *handler.Statement

func NewMultiStatement

func NewMultiStatement(event eventstore.Event, opts ...func(eventstore.Event) Exec) *handler.Statement

func NewMultiTableCheck

func NewMultiTableCheck(primaryTable *Table, secondaryTables ...*SuffixedTable) *handler.Check

func NewNoOpStatement

func NewNoOpStatement(event eventstore.Event) *handler.Statement

func NewTableCheck

func NewTableCheck(table *Table, opts ...execOption) *handler.Check

func NewUpdateStatement

func NewUpdateStatement(event eventstore.Event, values []handler.Column, conditions []handler.Condition, opts ...execOption) *handler.Statement

func NewUpsertStatement

func NewUpsertStatement(event eventstore.Event, conflictCols []handler.Column, values []handler.Column, opts ...execOption) *handler.Statement

func NewViewCheck

func NewViewCheck(selectStmt string, secondaryTables ...*SuffixedTable) *handler.Check

func WithTableSuffix

func WithTableSuffix(name string) func(*execConfig)

Types

type Column

type Column struct {
	Name string
	Type ColumnType
	// contains filtered or unexported fields
}

func NewColumn

func NewColumn(name string, columnType ColumnType, opts ...ColumnOption) *Column

type ColumnOption

type ColumnOption func(*Column)

func Default

func Default(value interface{}) ColumnOption

func DeleteCascade

func DeleteCascade(column string) ColumnOption

func Nullable

func Nullable() ColumnOption

type ColumnType

type ColumnType int32
const (
	ColumnTypeText ColumnType = iota
	ColumnTypeTextArray
	ColumnTypeJSONB
	ColumnTypeBytes
	ColumnTypeTimestamp
	ColumnTypeEnum
	ColumnTypeEnumArray
	ColumnTypeInt64
	ColumnTypeBool
)

type Constraint

type Constraint struct {
	Name    string
	Columns []string
}

func NewConstraint

func NewConstraint(name string, columns []string) *Constraint

type Exec

type Exec func(ex handler.Executer, projectionName string) error

type ForeignKey

type ForeignKey struct {
	Name       string
	Columns    []string
	RefColumns []string
}

func NewForeignKey

func NewForeignKey(name string, columns []string, refColumns []string) *ForeignKey

func NewForeignKeyOfPublicKeys

func NewForeignKeyOfPublicKeys(name string) *ForeignKey

type Index

type Index struct {
	Name    string
	Columns []string
	// contains filtered or unexported fields
}

func NewIndex

func NewIndex(name string, columns []string, opts ...indexOpts) *Index

type Locker

type Locker interface {
	Lock(ctx context.Context, lockDuration time.Duration, instanceIDs ...string) <-chan error
	Unlock(instanceIDs ...string) error
}

func NewLocker

func NewLocker(client *sql.DB, lockTable, projectionName string) Locker

type PrimaryKey

type PrimaryKey []string

func NewPrimaryKey

func NewPrimaryKey(columnNames ...string) PrimaryKey

type StatementHandler

type StatementHandler struct {
	*handler.ProjectionHandler
	Locker
	// contains filtered or unexported fields
}

func NewStatementHandler

func NewStatementHandler(
	ctx context.Context,
	config StatementHandlerConfig,
) StatementHandler

func (*StatementHandler) Init

func (h *StatementHandler) Init(ctx context.Context, initialized chan<- bool, checks ...*handler.Check) error

Init implements handler.Init

func (*StatementHandler) SearchQuery

func (h *StatementHandler) SearchQuery(ctx context.Context, instanceIDs []string) (*eventstore.SearchQueryBuilder, uint64, error)

func (*StatementHandler) Update

func (h *StatementHandler) Update(ctx context.Context, stmts []*handler.Statement, reduce handler.Reduce) (index int, err error)

Update implements handler.Update

type StatementHandlerConfig

type StatementHandlerConfig struct {
	handler.ProjectionHandlerConfig

	Client            *sql.DB
	SequenceTable     string
	LockTable         string
	FailedEventsTable string
	MaxFailureCount   uint
	BulkLimit         uint64

	Reducers  []handler.AggregateReducer
	InitCheck *handler.Check
}

type SuffixedTable

type SuffixedTable struct {
	Table
	// contains filtered or unexported fields
}

func NewSuffixedTable

func NewSuffixedTable(columns []*Column, key PrimaryKey, suffix string, opts ...TableOption) *SuffixedTable

type Table

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

func NewTable

func NewTable(columns []*Column, key PrimaryKey, opts ...TableOption) *Table

type TableOption

type TableOption func(*Table)

func WithConstraint

func WithConstraint(constraint *Constraint) TableOption

func WithForeignKey

func WithForeignKey(key *ForeignKey) TableOption

func WithIndex

func WithIndex(index *Index) TableOption

Jump to

Keyboard shortcuts

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