persistent

package
v5.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const BoltInMemoryMode = ":memory:"

BoltInMemoryMode used to store ramdom db into temporal folder

Variables

View Source
var ErrorBucketNotFound = errors.New("Bucket not found")

ErrorBucketNotFound error type for bucket not found

View Source
var ErrorKeyNotFound = errors.New("key not found")

ErrorKeyNotFound error type for key not found within a bucket

Functions

This section is empty.

Types

type BoltDBCollectionWrapper

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

BoltDBCollectionWrapper wraps a boltdb collection (aka bucket)

func (*BoltDBCollectionWrapper) Delete

func (c *BoltDBCollectionWrapper) Delete(key []byte) error

Delete removess an item into collection under key parameter

func (*BoltDBCollectionWrapper) Fetch

func (c *BoltDBCollectionWrapper) Fetch(id uint64) ([]byte, error)

Fetch returns an item from collection

func (*BoltDBCollectionWrapper) FetchAll

func (c *BoltDBCollectionWrapper) FetchAll() ([][]byte, error)

FetchAll fetch all saved items

func (*BoltDBCollectionWrapper) FetchBy

func (c *BoltDBCollectionWrapper) FetchBy(key []byte) ([]byte, error)

FetchBy returns an item from collection given a key

func (*BoltDBCollectionWrapper) Logger

Logger returns a reference to a logger

func (*BoltDBCollectionWrapper) Save

Save an item into collection setting autoincrement ID

func (*BoltDBCollectionWrapper) SaveAs

func (c *BoltDBCollectionWrapper) SaveAs(key []byte, item interface{}) error

SaveAs saves an item into collection under key parameter

func (*BoltDBCollectionWrapper) Update

Update an item into collection with current item ID

type BoltDBWrapper

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

BoltDBWrapper is a boltdb-based implmentation of a persistent storage wrapper

func NewBoltWrapper

func NewBoltWrapper(path string, options *bolt.Options) (*BoltDBWrapper, error)

NewBoltWrapper creates a new instance of BoltDB wrapper

func (*BoltDBWrapper) GetRawSnapshot

func (b *BoltDBWrapper) GetRawSnapshot() ([]byte, error)

GetRawSnapshot dumps all the contents of the db into a raw byte buffer

func (*BoltDBWrapper) Lock

func (b *BoltDBWrapper) Lock()

Lock grants exclusive access to the referenced db

func (*BoltDBWrapper) Unlock

func (b *BoltDBWrapper) Unlock()

Unlock reliquishes exclusive access to the referenced db

func (*BoltDBWrapper) Update

func (b *BoltDBWrapper) Update(f func(tx *bolt.Tx) error) error

Update executes a RW function within a transaction

func (*BoltDBWrapper) View

func (b *BoltDBWrapper) View(f func(tx *bolt.Tx) error) error

View executes a RO function wihtin a transaction

type CollectionItem

type CollectionItem interface {
	SetID(id uint64)
	ID() uint64
}

CollectionItem is the item into a collection

type CollectionWrapper

type CollectionWrapper interface {
	Delete(key []byte) error
	SaveAs(key []byte, item interface{}) error
	Save(item CollectionItem) (uint64, error)
	Update(item CollectionItem) error
	Fetch(id uint64) ([]byte, error)
	FetchBy(key []byte) ([]byte, error)
	FetchAll() ([][]byte, error)
	Logger() logging.LoggerInterface
}

CollectionWrapper defines the set of methods that should be implemented by a collection

type DBWrapper

type DBWrapper interface {
	Update(func(*bolt.Tx) error) error
	View(func(*bolt.Tx) error) error
	Lock()
	Unlock()
	GetRawSnapshot() ([]byte, error)
}

DBWrapper defines the interface for a Persistant storage wrapper

type SegmentChangesCollection

type SegmentChangesCollection interface {
	Update(name string, toAdd *set.ThreadUnsafeSet, toRemove *set.ThreadUnsafeSet, cn int64) error
	Fetch(name string) (*SegmentChangesItem, error)
	ChangeNumber(segment string) int64
	SetChangeNumber(segment string, cn int64)
}

type SegmentChangesCollectionImpl added in v5.4.2

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

SegmentChangesCollectionImpl represents a collection of SplitChangesItem

func NewSegmentChangesCollection

func NewSegmentChangesCollection(db DBWrapper, logger logging.LoggerInterface) *SegmentChangesCollectionImpl

NewSegmentChangesCollection returns an instance of SegmentChangesCollection

func (*SegmentChangesCollectionImpl) ChangeNumber added in v5.4.2

func (c *SegmentChangesCollectionImpl) ChangeNumber(segment string) int64

ChangeNumber returns changeNumber

func (*SegmentChangesCollectionImpl) Fetch added in v5.4.2

Fetch return a SegmentChangesItem

func (*SegmentChangesCollectionImpl) FetchAll added in v5.4.2

FetchAll return a list of SegmentChangesItem

func (*SegmentChangesCollectionImpl) SetChangeNumber added in v5.4.2

func (c *SegmentChangesCollectionImpl) SetChangeNumber(segment string, cn int64)

SetChangeNumber returns changeNumber

func (*SegmentChangesCollectionImpl) Update added in v5.4.2

func (c *SegmentChangesCollectionImpl) Update(name string, toAdd *set.ThreadUnsafeSet, toRemove *set.ThreadUnsafeSet, cn int64) error

Update persists a segmentChanges update

type SegmentChangesItem

type SegmentChangesItem struct {
	Name string
	Keys map[string]SegmentKey
}

SegmentChangesItem represents an SplitChanges service response

type SegmentKey

type SegmentKey struct {
	Name         string
	ChangeNumber int64
	Removed      bool
}

SegmentKey represents a segment key data

type SplitChangesCollection

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

SplitChangesCollection represents a collection of SplitChangesItem

func NewSplitChangesCollection

func NewSplitChangesCollection(db DBWrapper, logger logging.LoggerInterface) *SplitChangesCollection

NewSplitChangesCollection returns an instance of SplitChangesCollection

func (*SplitChangesCollection) ChangeNumber

func (c *SplitChangesCollection) ChangeNumber() int64

ChangeNumber returns changeNumber

func (*SplitChangesCollection) FetchAll

func (c *SplitChangesCollection) FetchAll() ([]dtos.SplitDTO, error)

FetchAll return a SplitChangesItem

func (*SplitChangesCollection) Update

func (c *SplitChangesCollection) Update(toAdd []dtos.SplitDTO, toRemove []dtos.SplitDTO, cn int64)

Update processes a set of feature flag changes items + a changeNumber bump atomically

type SplitChangesItem

type SplitChangesItem struct {
	ChangeNumber int64  `json:"changeNumber"`
	Name         string `json:"name"`
	Status       string `json:"status"`
	JSON         string
}

SplitChangesItem represents an SplitChanges service response

type SplitsChangesItems

type SplitsChangesItems []SplitChangesItem

SplitsChangesItems Sortable list

func (SplitsChangesItems) Len

func (slice SplitsChangesItems) Len() int

func (SplitsChangesItems) Less

func (slice SplitsChangesItems) Less(i, j int) bool

func (SplitsChangesItems) Swap

func (slice SplitsChangesItems) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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