flowdb

package module
v0.0.0-...-15b9bff Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2022 License: MIT Imports: 19 Imported by: 0

README

flowDB

Build

Setup

# build
go build -o flowdb-server cmd/server/main.go
go build -o flowdb-client cmd/client/main.go

# run cluster
./flowdb-server --server_config=server1.json
./flowdb-server --server_config=server2.json
./flowdb-server --server_config=server3.json

# run client
./flowdb-client --server_addr=127.0.0.1:7001
Node1 config (server1.json)
{
  "name": "node1",
  "host": "127.0.0.1",
  "port": 7001,
  "version": "0.1",
  "max_packet_size": 4096,
  "max_conn": 1000,
  "raft": {
    "id": "1",
    "addr": "127.0.0.1:5001",
    "cluster": "1/127.0.0.1:5001,2/127.0.0.1:5002,3/127.0.0.1:5003"
  }
}
Node2 config (server2.json)
{
  "name": "node2",
  "host": "127.0.0.1",
  "port": 7002,
  "version": "0.1",
  "max_packet_size": 4096,
  "max_conn": 1000,
  "raft": {
    "id": "2",
    "addr": "127.0.0.1:5002",
    "cluster": "1/127.0.0.1:5001,2/127.0.0.1:5002,3/127.0.0.1:5003"
  }
}
Node3 config (server3.json)
{
  "name": "node3",
  "host": "127.0.0.1",
  "port": 7003,
  "version": "0.1",
  "max_packet_size": 4096,
  "max_conn": 1000,
  "raft": {
    "id": "3",
    "addr": "127.0.0.1:5003",
    "cluster": "1/127.0.0.1:5001,2/127.0.0.1:5002,3/127.0.0.1:5003"
  }
}

Documentation

Index

Constants

View Source
const (
	FM    = os.FileMode(0750)
	FFlag = os.O_RDWR | os.O_APPEND | os.O_CREATE
)

Variables

This section is empty.

Functions

func Bootstrap

func Bootstrap(rf *raft.Raft, raftAddr, raftId, raftCluster string)

func EncodeEntry

func EncodeEntry(e *Entry) ([]byte, uint32)

EncodeEntry entry into binary

func EncodeHint

func EncodeHint(h *Hint) ([]byte, uint32)

func Hash

func Hash(key []byte) uint64

Types

type Entry

type Entry struct {
	CRC       uint32
	Timestamp uint64
	KeySize   uint32
	ValueSize uint32
	Key       []byte
	Value     []byte
}

func DecodeEntry

func DecodeEntry(data []byte) *Entry

DecodeEntry binary into entry

type FSM

type FSM struct {
	DataBase database
}

func NewFSM

func NewFSM() *FSM

func NewRaft

func NewRaft(raftAddr, raftId, raftDir string) (*raft.Raft, *FSM, error)

func (*FSM) Apply

func (f *FSM) Apply(log *raft.Log) interface{}

func (*FSM) Restore

func (f *FSM) Restore(snapshot io.ReadCloser) error

func (*FSM) Snapshot

func (f *FSM) Snapshot() (raft.FSMSnapshot, error)

type FlowDB

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

func New

func New(directory string) *FlowDB

func (*FlowDB) Close

func (f *FlowDB) Close() error

func (*FlowDB) Get

func (f *FlowDB) Get(key []byte) ([]byte, error)

func (*FlowDB) Load

func (f *FlowDB) Load() error

func (*FlowDB) Merge

func (f *FlowDB) Merge() error

func (*FlowDB) Put

func (f *FlowDB) Put(key, value []byte) error

func (*FlowDB) Sync

func (f *FlowDB) Sync() error

type Hint

type Hint struct {
	Timestamp uint64
	ValuePos  uint64
	Key       uint64
}

func DecodeHint

func DecodeHint(data []byte) *Hint

type KeyDirRecord

type KeyDirRecord struct {
	ValueSize uint32
	ValuePos  int64
	Timestamp int64
	// contains filtered or unexported fields
}

type Options

type Options struct {
	DatabaseDirectory string
}

func DefaultOptions

func DefaultOptions(directory string) Options

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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