lite

package
v1.2.3-fred.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2022 License: Apache-2.0 Imports: 19 Imported by: 39

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) 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) 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) GetRange

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

GetRange returns query range

func (*Backend) Import

func (l *Backend) Import(ctx context.Context, items []backend.Item) error

Import imports elements, makes sure elements are imported only once returns trace.AlreadyExists if elements have been imported

func (*Backend) Imported

func (l *Backend) Imported(ctx context.Context) (imported bool, err error)

Imported returns true if backend already imported data from another backend

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) PutRange

func (l *Backend) PutRange(ctx context.Context, items []backend.Item) error

PutRange puts range of items into backend (creates if items doe not exists, 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"`
	// Mirror turns on mirror mode for the backend,
	// which will use record IDs for Put and PutRange passed from
	// the resources, not generate a new one
	Mirror bool `json:"mirror"`
}

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.

type NullTime

type NullTime struct {
	Time  time.Time
	Valid bool // Valid is true if Time is not NULL
}

NullTime represents a time.Time that may be null. NullTime implements the sql.Scanner interface, so it can be used as a scan destination, similar to sql.NullString.

func (*NullTime) Scan

func (nt *NullTime) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullTime) Value

func (nt NullTime) Value() (driver.Value, error)

Value implements the driver Valuer interface.

Jump to

Keyboard shortcuts

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