Documentation ¶
Overview ¶
Package lite implements SQLite backend used for local persistent caches in proxies and nodes and for standalone auth service deployments.
Index ¶
- Constants
- func GetName() string
- type Config
- type LiteBackend
- func (l *LiteBackend) Clock() clockwork.Clock
- func (l *LiteBackend) Close() error
- func (l *LiteBackend) CompareAndSwap(ctx context.Context, expected backend.Item, replaceWith backend.Item) (*backend.Lease, error)
- func (l *LiteBackend) Create(ctx context.Context, i backend.Item) (*backend.Lease, error)
- func (l *LiteBackend) Delete(ctx context.Context, key []byte) error
- func (l *LiteBackend) DeleteRange(ctx context.Context, startKey, endKey []byte) error
- func (l *LiteBackend) Get(ctx context.Context, key []byte) (*backend.Item, error)
- func (l *LiteBackend) GetRange(ctx context.Context, startKey []byte, endKey []byte, limit int) (*backend.GetResult, error)
- func (l *LiteBackend) Import(ctx context.Context, items []backend.Item) error
- func (l *LiteBackend) Imported(ctx context.Context) (imported bool, err error)
- func (l *LiteBackend) KeepAlive(ctx context.Context, lease backend.Lease, expires time.Time) error
- func (l *LiteBackend) NewWatcher(ctx context.Context, watch backend.Watch) (backend.Watcher, error)
- func (l *LiteBackend) Put(ctx context.Context, i backend.Item) (*backend.Lease, error)
- func (l *LiteBackend) PutRange(ctx context.Context, items []backend.Item) error
- func (l *LiteBackend) SetClock(clock clockwork.Clock)
- func (l *LiteBackend) Update(ctx context.Context, i backend.Item) (*backend.Lease, error)
- type NullTime
Constants ¶
const (
// BackendName is the name of this backend
BackendName = "sqlite"
)
Variables ¶
This section is empty.
Functions ¶
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"` }
Config structure represents configuration section
func (*Config) CheckAndSetDefaults ¶
CheckAndSetDefaults is a helper returns an error if the supplied configuration is not enough to connect to sqlite
type LiteBackend ¶
LiteBackend uses SQLite to implement storage interfaces
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) 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) 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) GetRange ¶
func (l *LiteBackend) GetRange(ctx context.Context, startKey []byte, endKey []byte, limit int) (*backend.GetResult, error)
GetRange returns query range
func (*LiteBackend) Import ¶
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) NewWatcher ¶
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 ¶
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