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") ErrZSetMemberSize = errors.New("invalid zset member size")
) )
const (
MaxBinLogFileSize int = 1024 * 1024 * 1024
MaxBinLogFileNum int = 10000
DefaultBinLogFileSize int = MaxBinLogFileSize
DefaultBinLogFileNum int = 10
)
const ( const (
BinLogTypeDeletion uint8 = 0x0 BinLogTypeDeletion uint8 = 0x0
BinLogTypePut uint8 = 0x1 BinLogTypePut uint8 = 0x1

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
package ledis package replication
import ( import (
"io/ioutil" "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) {
}