sqlstash

package
v11.1.4-modfix Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCacheSize = 100

Variables

View Source
var (
	ReadCommitted = &sql.TxOptions{
		Isolation: sql.LevelReadCommitted,
	}
	ReadCommittedRO = &sql.TxOptions{
		Isolation: sql.LevelReadCommitted,
		ReadOnly:  true,
	}
)

TxOptions.

View Source
var (
	ErrNotFound                  = errors.New("entity not found")
	ErrOptimisticLockingFailed   = errors.New("optimistic locking failed")
	ErrUserNotFoundInContext     = errors.New("user not found in context")
	ErrNextPageTokenNotSupported = errors.New("nextPageToken not yet supported")
	ErrLimitNotSupported         = errors.New("limit not yet supported")
)

Package-level errors.

Functions

func NewSelectQuery

func NewSelectQuery(dialect migrator.Dialect, from string) *selectQuery

func ToAnyList

func ToAnyList[T any](input []T) []any

Types

type Broadcaster

type Broadcaster[T any] interface {
	Subscribe(context.Context) (<-chan T, error)
	Unsubscribe(chan T)
}

func NewBroadcaster

func NewBroadcaster[T any](ctx context.Context, connect ConnectFunc[T]) (Broadcaster[T], error)

type Cache

type Cache[T any] interface {
	Len() int
	Add(item T)
	Get(i int) T
	Range(f func(T) error) error
	Slice() []T
	ReadInto(dst chan T) error
}

func NewCache

func NewCache[T any](ctx context.Context, size int) Cache[T]

type ConnectFunc

type ConnectFunc[T any] func(chan T) error

type ContinueRequest

type ContinueRequest interface {
	GetNextPageToken() string
	GetSort() []string
}

type ContinueToken

type ContinueToken struct {
	Sort            []string `json:"s"`
	StartOffset     int64    `json:"o"`
	ResourceVersion int64    `json:"v"`
	RecordCnt       int64    `json:"c"`
}

func GetContinueToken

func GetContinueToken(r ContinueRequest) (*ContinueToken, error)

func (*ContinueToken) String

func (c *ContinueToken) String() string

type Direction

type Direction int
const (
	Ascending Direction = iota
	Descending
)

func (Direction) String

func (d Direction) String() string

type FieldSelectRequest

type FieldSelectRequest interface {
	GetWithBody() bool
	GetWithStatus() bool
}

type SQLError

type SQLError struct {
	Err          error
	CallType     string // either Query, QueryRow or Exec
	TemplateName string
	Query        string
	RawQuery     string
	ScanDest     []any
	// contains filtered or unexported fields
}

SQLError is an error returned by the database, which includes additionally debugging information about what was sent to the database.

func (SQLError) Error

func (e SQLError) Error() string

func (SQLError) Unwrap

func (e SQLError) Unwrap() error

type SortBy

type SortBy struct {
	Field     string
	Direction Direction
}

func ParseSortBy

func ParseSortBy(sort string) (SortBy, error)

type SqlEntityServer

type SqlEntityServer interface {
	entity.EntityStoreServer

	Init() error
	Stop()
}

func ProvideSQLEntityServer

func ProvideSQLEntityServer(db db.EntityDBInterface, tracer tracing.Tracer) (SqlEntityServer, error)

type StorageApiMetrics

type StorageApiMetrics struct {
	OptimisticLockFailed *prometheus.CounterVec
}
var (
	StorageServerMetrics *StorageApiMetrics
)

func NewStorageMetrics

func NewStorageMetrics() *StorageApiMetrics

func (*StorageApiMetrics) Collect

func (s *StorageApiMetrics) Collect(ch chan<- prometheus.Metric)

func (*StorageApiMetrics) Describe

func (s *StorageApiMetrics) Describe(ch chan<- *prometheus.Desc)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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