db

package
v0.0.0-...-5d4f8f2 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsErrRecFound

func IsErrRecFound(e error) bool

func IsErrRecNotFound

func IsErrRecNotFound(e error) bool

Types

type BadgerContext

type BadgerContext struct {
	Name string

	LastCall time.Time
	// contains filtered or unexported fields
}

func (*BadgerContext) Close

func (b *BadgerContext) Close()

func (*BadgerContext) Delete

func (b *BadgerContext) Delete(key string) error

func (*BadgerContext) DeleteIfExists

func (b *BadgerContext) DeleteIfExists(key string) error

func (*BadgerContext) Get

func (b *BadgerContext) Get(key string) ([]byte, error)

func (*BadgerContext) GetListener

func (b *BadgerContext) GetListener() ChangeListener

func (*BadgerContext) Insert

func (b *BadgerContext) Insert(key string, value interface{}) error

func (*BadgerContext) KeyExists

func (b *BadgerContext) KeyExists(key string) bool

func (*BadgerContext) SoftDelete

func (b *BadgerContext) SoftDelete(key string) error

func (*BadgerContext) Update

func (b *BadgerContext) Update(key string, value interface{}) error

func (*BadgerContext) UpdateAndTrack

func (b *BadgerContext) UpdateAndTrack(key string, value interface{}, template interface{}) error

func (*BadgerContext) Upsert

func (b *BadgerContext) Upsert(key string, value interface{}) error

type Body

type Body map[string]interface{}

type ChangeListener

type ChangeListener interface {
	RegisterObject(newch chan<- interface{}, objType interface{})

	Listen()

	// Register a new channel to receive broadcasts
	Register(chan<- interface{})

	// Unregister a channel so that it no longer receives broadcasts.
	Unregister(chan<- interface{})

	// Shut this broadcaster down.
	Close() error

	// Submit a new object to all subscribers
	TrackEvent(interface{}, interface{})
}

func NewChangeListener

func NewChangeListener(buflen int) ChangeListener

type DatabaseContext

type DatabaseContext interface {
	Get(key string) ([]byte, error)
	Insert(key string, value interface{}) error
	Update(key string, value interface{}) error
	UpdateAndTrack(key string, value interface{}, template interface{}) error
	Upsert(key string, value interface{}) error

	DeleteIfExists(key string) error
	Delete(key string) error
	SoftDelete(key string) error
	KeyExists(key string) bool
	GetListener() ChangeListener
	Close()
}

func NewBadgerContext

func NewBadgerContext(name, datapath string) (DatabaseContext, error)

func NewDatabaseContext

func NewDatabaseContext(c *config.DBConfig) (DatabaseContext, error)

func NewPGContext

func NewPGContext(name, user, pass string) (DatabaseContext, error)

type ErrRecAlreadyExists

type ErrRecAlreadyExists struct {
	Type string
	Key  string
}

Error when key exists when it shouldnt

func (ErrRecAlreadyExists) Error

func (e ErrRecAlreadyExists) Error() string

type ErrRecNotFound

type ErrRecNotFound struct {
	Type string
	Key  string
}

Custom error when record is not found

func (ErrRecNotFound) Error

func (e ErrRecNotFound) Error() string

type PGContext

type PGContext struct {
	Name string

	LastCall time.Time
	Listener ChangeListener
	// contains filtered or unexported fields
}

func (*PGContext) Close

func (p *PGContext) Close()

func (*PGContext) Delete

func (p *PGContext) Delete(key string) error

func (*PGContext) DeleteIfExists

func (p *PGContext) DeleteIfExists(key string) error

func (*PGContext) Get

func (p *PGContext) Get(key string) ([]byte, error)

func (*PGContext) GetListener

func (p *PGContext) GetListener() ChangeListener

func (*PGContext) Insert

func (p *PGContext) Insert(key string, value interface{}) error

func (*PGContext) KeyExists

func (p *PGContext) KeyExists(key string) bool

func (*PGContext) SoftDelete

func (p *PGContext) SoftDelete(key string) error

func (*PGContext) Update

func (p *PGContext) Update(key string, value interface{}) error

TODO: raises error if key is missing

func (*PGContext) UpdateAndTrack

func (p *PGContext) UpdateAndTrack(key string, value interface{}, template interface{}) error

a bad hack to enable tracking of updates

func (*PGContext) Upsert

func (p *PGContext) Upsert(key string, value interface{}) error

Jump to

Keyboard shortcuts

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