db

package
v0.0.0-...-6b04d54 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 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

IsErrRecFound :

func IsErrRecNotFound

func IsErrRecNotFound(e error) bool

IsErrRecNotFound :

Types

type BadgerContext

type BadgerContext struct {
	Name string

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

BadgerContext :

func (*BadgerContext) Close

func (b *BadgerContext) Close()

Close : close the db

func (*BadgerContext) Delete

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

Delete : Delete only if key exists. should be soft delete?

func (*BadgerContext) DeleteIfExists

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

DeleteIfExists : Delete a row if it exists

func (*BadgerContext) Get

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

Get : Data getter

func (*BadgerContext) GetListener

func (b *BadgerContext) GetListener() ChangeListener

GetListener : Get Listener for row changes

func (*BadgerContext) GetSequence

func (b *BadgerContext) GetSequence(kind string, cache uint64) (uint64, error)

GetSequence :

func (*BadgerContext) Insert

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

Insert : data insert routine

func (*BadgerContext) InsertAndTrack

func (b *BadgerContext) InsertAndTrack(key string, value interface{}, templates ...interface{}) error

InsertAndTrack : Insert and Track with a trigger

func (*BadgerContext) InsertIndex

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

InsertIndex : data insert index

func (*BadgerContext) KeyExists

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

KeyExists : check if a key exists

func (*BadgerContext) List

func (b *BadgerContext) List(prefix []byte) ([][]byte, error)

List :

func (*BadgerContext) ListKeys

func (b *BadgerContext) ListKeys(prefix []byte) ([][]byte, error)

ListKeys :

func (*BadgerContext) SoftDelete

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

SoftDelete : Changes key to deleted: so it is not found when actual key search occurs but exists in DB

func (*BadgerContext) Update

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

Update : data row update

func (*BadgerContext) UpdateAndTrack

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

UpdateAndTrack : Updates with a trigger

func (*BadgerContext) Upsert

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

Upsert : Data row merge

type Body

type Body map[string]interface{}

Body :

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{})
}

ChangeListener : Row change listener

func NewChangeListener

func NewChangeListener(buflen int) ChangeListener

NewChangeListener :

type DatabaseContext

type DatabaseContext interface {
	GetSequence(kind string, cache uint64) (uint64, error)
	Get(key string) ([]byte, error)
	Insert(key string, value interface{}) error
	InsertIndex(key string) error

	InsertAndTrack(key string, value interface{}, templates ...interface{}) error
	Update(key string, value interface{}) error
	UpdateAndTrack(key string, value interface{}, templates ...interface{}) error
	Upsert(key string, value interface{}) error

	List(prefix []byte) ([][]byte, error)
	ListKeys(prefix []byte) ([][]byte, error)

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

DatabaseContext :

func NewBadgerContext

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

NewBadgerContext : Creates a new badger conn

func NewDatabaseContext

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

NewDatabaseContext :

func NewPGContext

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

NewPGContext :

type ErrRecAlreadyExists

type ErrRecAlreadyExists struct {
	Type string
	Key  string
}

ErrRecAlreadyExists : Error when key exists when it shouldnt

func (ErrRecAlreadyExists) Error

func (e ErrRecAlreadyExists) Error() string

type ErrRecNotFound

type ErrRecNotFound struct {
	Type string
	Key  string
}

ErrRecNotFound : 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
}

PGContext :

func (*PGContext) Close

func (p *PGContext) Close()

Close :

func (*PGContext) Delete

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

Delete : TODO: throw error if rec doesnt exist

func (*PGContext) DeleteIfExists

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

DeleteIfExists :

func (*PGContext) Get

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

Get :

func (*PGContext) GetListener

func (p *PGContext) GetListener() ChangeListener

GetListener :

func (*PGContext) Insert

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

Insert : DB Insert

func (*PGContext) KeyExists

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

KeyExists :

func (*PGContext) SoftDelete

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

SoftDelete :

func (*PGContext) Update

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

Update : TODO: raises error if key is missing

func (*PGContext) UpdateAndTrack

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

UpdateAndTrack : a bad hack to enable tracking of updates

func (*PGContext) Upsert

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

Upsert :

Jump to

Keyboard shortcuts

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