trounoirDB

package
v0.0.0-...-a414a30 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2016 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Items     []ConfigItem `json:"items"`
	Port      int          `json:"port"`
	CopyRange int          `json:"copy_range"`
	Salt      string       `json:"salt"`
	Folder    string       `json:"folder"`
}

spread 1 2 3 4 1 -> 2 3 2 -> 3 4 3 -> 4 1 4 -> 1 2

to scale up, 1) add cluster 5 2) add 5 to config file of 4 3) restart 4, during restarting 1 2 3 5 will be keep active 4) change config 3, restart 3, during restart 1 2 4 5 will be active 5) change config 2, restart 2, during restart 1 3 4 5 will be active 6) do the rest, config and restart one by one

to scale down change config 3 dup, from 4 1 to 4 2, restart change config 4 dup, from 1 2 to 2 3, restart stop 1 do the rest, config and restart one by one

func (*Config) GetLocalConfig

func (config *Config) GetLocalConfig() (*LocalConfig, error)

run at app start time, loop through

func (*Config) Parse

func (config *Config) Parse(config_path string) error

parse the json file, return errors if found any

type ConfigItem

type ConfigItem struct {
	Host    string `json:"host"`
	IsLocal bool   `json:"islocal"`
}

for example c1 host: 192.168.0.12 islocal: true

type DB

type DB struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*DB) GetTable

func (db *DB) GetTable(name string) *DBTable

func (*DB) LoadTable

func (db *DB) LoadTable(name string) error

CreateTable will do the following create memTable create local boltDB file, return err if can't create send rpc to all db

type DBTable

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

type Doc

type Doc interface {
}

type LocalConfig

type LocalConfig struct {
	Self ConfigItem
	Dup  []ConfigItem
}

local config dup must exclude self for a forward request, send forward request to dup

type MemTable

type MemTable struct {
	sync.RWMutex
	Data map[string]memDataItem
	// contains filtered or unexported fields
}

func (*MemTable) Run

func (mt *MemTable) Run()

type Method

type Method int

type Request

type Request struct {
	IsRemote   bool
	Timestamp  int64
	SecureHash []byte
	Bucket     string
	Key        string
	Value      interface{}
	MRQuery    []byte
}

func (*Request) GenSecure

func (r *Request) GenSecure(salt string)

generate secure hash with timestamp One time password generator for each request

func (*Request) Verify

func (r *Request) Verify(salt string) bool

verify if the request is real

type Table

type Table interface {
	Path() string
	Put(key string, b []byte) error
	Get(key string) ([]byte, error)
}

func CreateTable

func CreateTable(name string, cfg Config) (Table, error)

CreateTable will create a boltdb file under the folder

func NewTable

func NewTable(name, path string) Table

NewTable init a new table object

type Timestamp

type Timestamp int64

Jump to

Keyboard shortcuts

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