datasource

package
v0.0.0-...-8337c00 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultNS = "default"
)

Variables

View Source
var (
	ErrUnknownProtocol error = errors.New("unknown protocol")
	ErrNotExist        error = errors.New("no such item")
)

Functions

This section is empty.

Types

type DataSource

type DataSource interface {
	Get(key []byte) (Item, error)
	List(keyPrfix []byte, opts ListOpt) ([]Item, error)
	Put(key, value []byte, meta ItemMeta) error
	Remove(key []byte) error
	Init(dsn string) error
	Sync() error
}

func Init

func Init(dsn string) (DataSource, error)

type Item

type Item struct {
	Key   []byte
	Value []byte
	Meta  ItemMeta
}

type ItemMeta

type ItemMeta struct {
	Tp        ItemType
	Len       int
	CreateAt  time.Time
	Tags      []string
	Namespace string
}

type ItemType

type ItemType int
const (
	TypeBytes ItemType = iota + 1
	TypeJSON
)

type Items

type Items struct {
	gorm.Model
	Key          string // primary key
	JsonContent  []byte // TODO, json column
	BytesContent []byte
	Namespace    string   // namespace
	Tags         []string // index
	CreateAt     time.Time
}

type JsonRPCDatasource

type JsonRPCDatasource struct {
}

func (*JsonRPCDatasource) Get

func (j *JsonRPCDatasource) Get(key []byte) (Item, error)

func (*JsonRPCDatasource) Init

func (j *JsonRPCDatasource) Init(dsn string) error

func (*JsonRPCDatasource) List

func (j *JsonRPCDatasource) List(keyPrfix []byte, opts ListOpt) ([]Item, error)

func (*JsonRPCDatasource) Put

func (j *JsonRPCDatasource) Put(key []byte, value []byte, meta ItemMeta) error

func (*JsonRPCDatasource) Remove

func (j *JsonRPCDatasource) Remove(key []byte) error

func (*JsonRPCDatasource) Sync

func (j *JsonRPCDatasource) Sync() error

type ListOpt

type ListOpt interface{}

type MySQLDatasource

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

func (*MySQLDatasource) Get

func (m *MySQLDatasource) Get(key []byte) (Item, error)

func (*MySQLDatasource) Init

func (m *MySQLDatasource) Init(dsn string) error

func (*MySQLDatasource) List

func (m *MySQLDatasource) List(keyPrfix []byte, opts ListOpt) ([]Item, error)

func (*MySQLDatasource) Put

func (m *MySQLDatasource) Put(key []byte, value []byte, meta ItemMeta) error

func (*MySQLDatasource) Remove

func (m *MySQLDatasource) Remove(key []byte) error

func (*MySQLDatasource) Sync

func (m *MySQLDatasource) Sync() error

Jump to

Keyboard shortcuts

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