lite

package
v0.0.0-...-5c79d48 Latest Latest
Warning

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

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

Documentation

Overview

Package lite implements SQLite backend used for local persistent caches in proxies and nodes and for standalone auth service deployments.

Index

Constants

View Source
const (
	// BackendName is the name of this backend.
	BackendName = "sqlite"
	// AlternativeName is another name of this backend.
	AlternativeName = "dir"

	// SyncFull fsyncs the database file on disk after every write.
	SyncFull = "FULL"

	// JournalMemory keeps the rollback journal in memory instead of storing it
	// on disk.
	JournalMemory = "MEMORY"
)

Variables

This section is empty.

Functions

func GetName

func GetName() string

GetName is a part of backend API and it returns SQLite backend type as it appears in `storage/type` section of Teleport YAML

Types

type Backend

type Backend struct {
	Config
	*log.Entry
	// contains filtered or unexported fields
}

Backend uses SQLite to implement storage interfaces

func New

func New(ctx context.Context, params backend.Params) (*Backend, error)

New returns a new instance of sqlite backend

func NewWithConfig

func NewWithConfig(ctx context.Context, cfg Config) (*Backend, error)

NewWithConfig returns a new instance of lite backend using configuration struct as a parameter

func (*Backend) AtomicWrite

func (l *Backend) AtomicWrite(ctx context.Context, condacts []backend.ConditionalAction) (revision string, err error)

func (*Backend) Clock

func (l *Backend) Clock() clockwork.Clock

Clock returns clock used by the backend

func (*Backend) Close

func (l *Backend) Close() error

Close closes all associated resources

func (*Backend) CloseWatchers

func (l *Backend) CloseWatchers()

CloseWatchers closes all the watchers without closing the backend

func (*Backend) CompareAndSwap

func (l *Backend) CompareAndSwap(ctx context.Context, expected backend.Item, replaceWith backend.Item) (*backend.Lease, error)

CompareAndSwap compares item with existing item and replaces is with replaceWith item

func (*Backend) ConditionalDelete

func (l *Backend) ConditionalDelete(ctx context.Context, key []byte, revision string) error

func (*Backend) ConditionalUpdate

func (l *Backend) ConditionalUpdate(ctx context.Context, i backend.Item) (*backend.Lease, error)

func (*Backend) Create

func (l *Backend) Create(ctx context.Context, i backend.Item) (*backend.Lease, error)

Create creates item if it does not exist

func (*Backend) Delete

func (l *Backend) Delete(ctx context.Context, key []byte) error

Delete deletes item by key, returns NotFound error if item does not exist

func (*Backend) DeleteRange

func (l *Backend) DeleteRange(ctx context.Context, startKey, endKey []byte) error

DeleteRange deletes range of items with keys between startKey and endKey Note that elements deleted by range do not produce any events

func (*Backend) Get

func (l *Backend) Get(ctx context.Context, key []byte) (*backend.Item, error)

Get returns a single item or not found error

func (*Backend) GetName

func (l *Backend) GetName() string

func (*Backend) GetRange

func (l *Backend) GetRange(ctx context.Context, startKey []byte, endKey []byte, limit int) (*backend.GetResult, error)

GetRange returns query range

func (*Backend) KeepAlive

func (l *Backend) KeepAlive(ctx context.Context, lease backend.Lease, expires time.Time) error

KeepAlive updates TTL on the lease

func (*Backend) NewWatcher

func (l *Backend) NewWatcher(ctx context.Context, watch backend.Watch) (backend.Watcher, error)

NewWatcher returns a new event watcher

func (*Backend) Put

func (l *Backend) Put(ctx context.Context, i backend.Item) (*backend.Lease, error)

Put puts value into backend (creates if it does not exist, updates it otherwise)

func (*Backend) SetClock

func (l *Backend) SetClock(clock clockwork.Clock)

SetClock sets internal backend clock

func (*Backend) Update

func (l *Backend) Update(ctx context.Context, i backend.Item) (*backend.Lease, error)

Update updates value in the backend

type Config

type Config struct {
	// Path is a path to the database directory
	Path string `json:"path,omitempty"`
	// BufferSize is a default buffer size
	// used to pull events
	BufferSize int `json:"buffer_size,omitempty"`
	// PollStreamPeriod is a polling period for event stream
	PollStreamPeriod time.Duration `json:"poll_stream_period,omitempty"`
	// EventsOff turns events off
	EventsOff bool `json:"events_off,omitempty"`
	// Clock allows to override clock used in the backend
	Clock clockwork.Clock `json:"-"`
	// Sync sets the synchronous pragma
	Sync string `json:"sync,omitempty"`
	// BusyTimeout sets busy timeout in milliseconds
	BusyTimeout int `json:"busy_timeout,omitempty"`
	// Journal sets the journal_mode pragma
	Journal string `json:"journal,omitempty"`
}

Config structure represents configuration section

func (*Config) CheckAndSetDefaults

func (cfg *Config) CheckAndSetDefaults() error

CheckAndSetDefaults is a helper returns an error if the supplied configuration is not enough to connect to sqlite

func (*Config) ConnectionURI

func (cfg *Config) ConnectionURI() string

ConnectionURI returns a connection string usable with sqlite according to the Config.

Jump to

Keyboard shortcuts

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