lite

package
v4.2.3-beta.1+incompat... Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2020 License: Apache-2.0 Imports: 16 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"
)

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 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 synchronous pragrma
	Sync string `json:"sync,omitempty"`
	// BusyTimeout sets busy timeout in milliseconds
	BusyTimeout int `json:"busy_timeout,omitempty"`
	// Memory turns memory mode of the database
	Memory bool `json:"memory"`
	// MemoryName sets the name of the database,
	// set to "sqlite.db" by default
	MemoryName string `json:"memory_name"`
	// 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

type LiteBackend

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

LiteBackend uses SQLite to implement storage interfaces

func New

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

New returns a new instance of sqlite backend

func NewWithConfig

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

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

func (*LiteBackend) Clock

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

Clock returns clock used by the backend

func (*LiteBackend) Close

func (l *LiteBackend) Close() error

Close closes all associated resources

func (*LiteBackend) CloseWatchers

func (l *LiteBackend) CloseWatchers()

CloseWatchers closes all the watchers without closing the backend

func (*LiteBackend) CompareAndSwap

func (l *LiteBackend) 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 (*LiteBackend) Create

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

Create creates item if it does not exist

func (*LiteBackend) Delete

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

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

func (*LiteBackend) DeleteRange

func (l *LiteBackend) 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 (*LiteBackend) Get

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

Get returns a single item or not found error

func (*LiteBackend) GetRange

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

GetRange returns query range

func (*LiteBackend) Import

func (l *LiteBackend) 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 (*LiteBackend) Imported

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

Imported returns true if backend already imported data from another backend

func (*LiteBackend) KeepAlive

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

KeepAlive updates TTL on the lease

func (*LiteBackend) NewWatcher

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

NewWatcher returns a new event watcher

func (*LiteBackend) Put

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

func (*LiteBackend) PutRange

func (l *LiteBackend) 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 (*LiteBackend) SetClock

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

SetClock sets internal backend clock

func (*LiteBackend) Update

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

Update updates value in the backend

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