driver

package
v0.0.0-...-aec85aa Latest Latest
Warning

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

Go to latest
Published: May 25, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExists        = errors.New("key exists")
	ErrNotExists     = errors.New("key and or Revision does not exists")
	ErrRevisionMatch = errors.New("revision does not match")
)

Functions

This section is empty.

Types

type Driver

type Driver interface {
	List(ctx context.Context, revision, limit int64, rangeKey, startKey string) (kvs []*KeyValue, listRevision int64, err error)

	Delete(ctx context.Context, key string, revision int64) ([]*KeyValue, error)

	// Update should return ErrNotExist when the key does not exist and ErrRevisionMatch when revision doesn't match
	Update(ctx context.Context, key string, value []byte, revision, ttl int64) (oldKv *KeyValue, newKv *KeyValue, err error)

	Watch(ctx context.Context, key string, revision int64) <-chan Event

	Close() error
}

type Event

type Event struct {
	KV    *KeyValue
	Err   error
	Start bool
}

type Generic

type Generic struct {
	CleanupSQL      string
	GetSQL          string
	ListSQL         string
	ListRevisionSQL string
	ListResumeSQL   string
	ReplaySQL       string
	InsertSQL       string
	GetRevisionSQL  string
	ToDeleteSQL     string
	DeleteOldSQL    string
	// contains filtered or unexported fields
}

func (*Generic) Close

func (g *Generic) Close() error

Close closes the watcher and cancels all watch requests.

func (*Generic) Delete

func (g *Generic) Delete(ctx context.Context, key string, revision int64) ([]*KeyValue, error)

func (*Generic) ExecContext

func (g *Generic) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func (*Generic) Get

func (g *Generic) Get(ctx context.Context, key string) (*KeyValue, error)

func (*Generic) List

func (g *Generic) List(ctx context.Context, revision, limit int64, rangeKey, startKey string) ([]*KeyValue, int64, error)

func (*Generic) QueryContext

func (g *Generic) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

func (*Generic) Start

func (g *Generic) Start(ctx context.Context, db *sql.DB) error

func (*Generic) Update

func (g *Generic) Update(ctx context.Context, key string, value []byte, revision, ttl int64) (*KeyValue, *KeyValue, error)

func (*Generic) Watch

func (g *Generic) Watch(ctx context.Context, key string, revision int64) <-chan Event

type KeyValue

type KeyValue struct {
	ID             int64
	Key            string
	Value          []byte
	OldValue       []byte
	OldRevision    int64
	CreateRevision int64
	Revision       int64
	TTL            int64
	Version        int64
	Del            int64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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