core

package
v0.0.0-...-12949dc Latest Latest
Warning

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

Go to latest
Published: May 20, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayIntersect

func ArrayIntersect(a, b []string) []string

ArrayIntersect Performs Intersection of two string array intersection of (m1, m3) (m1, m4) = (m1) any empty array results in no results

func CheckResults

func CheckResults(jsres, jsexpected []byte) error

CheckResults current vs expected to error in case there is a mismatch

func DeSerializeStore

func DeSerializeStore(s Store, jsBuffer []byte) error

DeSerializeStore deserializes JSON and Updates current store useful to restore store or for updating alternate store {"key1" : {"propkey1" : "propvalue1", "propkey2" : "propvalue2"}, "key2" ...}

func GenerateKey

func GenerateKey(key, val string) string

GenerateKey returns hash of key value used as a Store Key

func InitializeStore

func InitializeStore(s Store, cfg Config) error

InitializeStore with optional configuration

func QueryStore

func QueryStore(s Store, jsQuery []byte) ([]byte, error)

QueryStore with single/multiple properties Properties are AND only, if an OR is required, query multiple times OR could be supported, but keeping it simple for now

func SerializeStore

func SerializeStore(s Store) ([]byte, error)

SerializeStore to JSON useful to backup store or for syncing to other stores {"propkey1:propvalue1" : ["key1", "key2"], "propkey2:propvalue2" : ["key2"] ...}

func ShutdownStore

func ShutdownStore(s Store) error

ShutdownStore to close any open file handles, or flush keys to store

func UpdateStore

func UpdateStore(s Store, byt []byte) error

UpdateStore called with list of Key and Associated properties Check for consistncy of input json Converts {"m1": {"num": "6.13","strs": "a","key1": "b"}, "m2": {"num": "6.13","key1": "bddd"}} To {"num:6.13" : ["m1", m2"], "strs:a" : ["m1"], "key1:b" : ["m1"], "key1:bddd" : ["m2"]}

Types

type BadgerStore

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

BadgerStore store for db

func (*BadgerStore) Initialize

func (s *BadgerStore) Initialize(cfg Config) error

Initialize Store with custom configuration

func (*BadgerStore) Query

func (s *BadgerStore) Query(key string) ([]string, error)

Query for key, return value would be a list of keys associated with the property

func (*BadgerStore) Serialize

func (s *BadgerStore) Serialize() (map[string][]string, error)

Serialize store to backup, could be optionally compressed

func (*BadgerStore) Shutdown

func (s *BadgerStore) Shutdown() error

Shutdown db, by closing all the open handles

func (*BadgerStore) Update

func (s *BadgerStore) Update(key, value string) error

Update db with key value pair

type BoltStore

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

BoltStore (Key, Value), value in JSON format

func (*BoltStore) Initialize

func (s *BoltStore) Initialize(cfg Config) error

Initialize Store with custom configuration

func (*BoltStore) Query

func (s *BoltStore) Query(key string) ([]string, error)

Query for key, return value would be a list of keys associated with the property

func (*BoltStore) Serialize

func (s *BoltStore) Serialize() (map[string][]string, error)

Serialize store to backup, could be optionally compressed

func (*BoltStore) Shutdown

func (s *BoltStore) Shutdown() error

Shutdown db, by closing all the open handles

func (*BoltStore) Update

func (s *BoltStore) Update(key, value string) error

Update db with key value pair

type BoltStoreConfig

type BoltStoreConfig struct {
	Path    string
	Mode    os.FileMode
	Options *bolt.Options
}

BoltStoreConfig configuration for path, filemode and options

type Config

type Config interface {
}

Config provides a interface for stores to have additional config provided during initialization Example: boltdb/badgerdb could provide directory name to store the db

type InMemoryStore

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

InMemoryStore is Concurrent friendly Store Map of Property and List of Keys associated with that property

func (*InMemoryStore) Initialize

func (s *InMemoryStore) Initialize(cfg Config) error

Initialize Store with custom configuration

func (*InMemoryStore) Query

func (s *InMemoryStore) Query(key string) ([]string, error)

Query for key, return value would be a list of keys associated with the property

func (*InMemoryStore) Serialize

func (s *InMemoryStore) Serialize() (map[string][]string, error)

Serialize store to backup, could be optionally compressed

func (*InMemoryStore) Shutdown

func (s *InMemoryStore) Shutdown() error

Shutdown -Not much to do since its inmemory

func (*InMemoryStore) Update

func (s *InMemoryStore) Update(key, value string) error

Update key value pair

type Store

type Store interface {
	Initialize(cfg Config) error
	Shutdown() error
	Update(key, value string) error
	Query(key string) ([]string, error)
	Serialize() (map[string][]string, error)
}

Store interface

Jump to

Keyboard shortcuts

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