move bin log to replication package

This commit is contained in:
siddontang 2014-06-03 09:51:29 +08:00
parent 2b106981ba
commit 8cc62ad89f
7 changed files with 29 additions and 14 deletions

View File

@ -43,14 +43,6 @@ var (
ErrZSetMemberSize = errors.New("invalid zset member size")
)
const (
MaxBinLogFileSize int = 1024 * 1024 * 1024
MaxBinLogFileNum int = 10000
DefaultBinLogFileSize int = MaxBinLogFileSize
DefaultBinLogFileNum int = 10
)
const (
BinLogTypeDeletion uint8 = 0x0
BinLogTypePut uint8 = 0x1

View File

@ -4,13 +4,14 @@ import (
"encoding/json"
"fmt"
"github.com/siddontang/go-leveldb/leveldb"
"github.com/siddontang/ledisdb/replication"
"sync"
)
type Config struct {
DataDB leveldb.Config `json:"data_db"`
BinLog BinLogConfig `json:"binlog"`
BinLog replication.BinLogConfig `json:"binlog"`
}
type DB struct {
@ -32,7 +33,7 @@ type Ledis struct {
ldb *leveldb.DB
dbs [MaxDBNumber]*DB
binlog *BinLog
binlog *replication.BinLog
}
func Open(configJson json.RawMessage) (*Ledis, error) {
@ -55,7 +56,7 @@ func OpenWithConfig(cfg *Config) (*Ledis, error) {
l.ldb = ldb
if len(cfg.BinLog.Path) > 0 {
l.binlog, err = NewBinLogWithConfig(&cfg.BinLog)
l.binlog, err = replication.NewBinLogWithConfig(&cfg.BinLog)
if err != nil {
return nil, err
}

View File

@ -2,6 +2,7 @@ package ledis
import (
"github.com/siddontang/go-leveldb/leveldb"
"github.com/siddontang/ledisdb/replication"
"sync"
)
@ -11,7 +12,7 @@ type tx struct {
l *Ledis
wb *leveldb.WriteBatch
binlog *BinLog
binlog *replication.BinLog
batch [][]byte
}

View File

@ -1,4 +1,4 @@
package ledis
package replication
import (
"bufio"
@ -14,6 +14,14 @@ import (
"time"
)
const (
MaxBinLogFileSize int = 1024 * 1024 * 1024
MaxBinLogFileNum int = 10000
DefaultBinLogFileSize int = MaxBinLogFileSize
DefaultBinLogFileNum int = 10
)
/*
index file format:
ledis-bin.00001

View File

@ -1,4 +1,4 @@
package ledis
package replication
import (
"io/ioutil"

4
replication/relaylog.go Normal file
View File

@ -0,0 +1,4 @@
package replication
type RelayLog struct {
}

View File

@ -0,0 +1,9 @@
package replication
import (
"testing"
)
func TestRelayLog(t *testing.T) {
}