datastore

package
v0.0.0-...-4bb274d Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2021 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSuchToken = errors.New("no such token")
)

Errors returned by Datastore.

Functions

This section is empty.

Types

type Datastore

type Datastore interface {
	HealthChecker
	Inserter
	Lister
}

Datastore is the main interface into the db package.

type HealthChecker

type HealthChecker interface {
	Healthcheck() (bool, error)
}

HealthChecker is the interface for performming healthchecks against the Datastore.

type Inserter

type Inserter interface {
	Insert(token string, lines []string) (int, error)
}

Inserter is the interface for inserting records into the Datastore.

type Lister

type Lister interface {
	List(token string) ([]string, error)
}

Lister is the interface for listing logs stored in the Datastore.

type MemoryDB

type MemoryDB struct {
	// contains filtered or unexported fields
}

MemoryDB implements an in memory Datastore.

func NewInMemory

func NewInMemory(keep int) (*MemoryDB, error)

NewInMemory creates a new in memory Datastore.

func (*MemoryDB) Healthcheck

func (db *MemoryDB) Healthcheck() (bool, error)

Healthcheck always return true.

func (*MemoryDB) Insert

func (db *MemoryDB) Insert(token string, lines []string) (int, error)

Insert inserts logs into in memory ring buffer.

func (*MemoryDB) List

func (db *MemoryDB) List(token string) ([]string, error)

List lists the stored in memory logs

type RedisDB

type RedisDB struct {
	// contains filtered or unexported fields
}

RedisDB is the redis implementation of the Datastore interface.

func NewInRedis

func NewInRedis(u *url.URL, keep, size int) (*RedisDB, error)

NewInRedis creates an instance of RedisDB.

func (*RedisDB) Healthcheck

func (db *RedisDB) Healthcheck() (bool, error)

Healthcheck performs a PING against redis.

func (*RedisDB) Insert

func (db *RedisDB) Insert(token string, lines []string) (int, error)

Insert inserts a batch into redis.

func (*RedisDB) List

func (db *RedisDB) List(token string) ([]string, error)

List performs LRANGE agains redis.

Jump to

Keyboard shortcuts

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