Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Terry-Mao committed Mar 14, 2016
1 parent 94621b1 commit 515d37d
Show file tree
Hide file tree
Showing 134 changed files with 23,875 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# bfs
distributed file system(small file storage) writen by golang according to facebook haystack.
71 changes: 71 additions & 0 deletions directory/conf/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package conf

import (
"github.com/BurntSushi/toml"
"io/ioutil"
"os"
"time"
)

type Config struct {
Snowflake *Snowflake
Zookeeper *Zookeeper
HBase *HBase

MaxNum int
ApiListen string
PprofEnable bool
PprofListen string
}

type Snowflake struct {
ZkAddrs []string
ZkTimeout duration
ZkPath string
WorkId int64
}

type Zookeeper struct {
Addrs []string
Timeout duration
PullInterval duration
VolumeRoot string
StoreRoot string
GroupRoot string
}

type HBase struct {
Addr string
MaxActive int
MaxIdle int
Timeout duration
LvsTimeout duration
}

// Code to implement the TextUnmarshaler interface for `duration`:
type duration struct {
time.Duration
}

func (d *duration) UnmarshalText(text []byte) error {
var err error
d.Duration, err = time.ParseDuration(string(text))
return err
}

// NewConfig new a config.
func NewConfig(conf string) (c *Config, err error) {
var (
file *os.File
blob []byte
)
c = new(Config)
if file, err = os.Open(conf); err != nil {
return
}
if blob, err = ioutil.ReadAll(file); err != nil {
return
}
err = toml.Unmarshal(blob, c)
return
}
Loading

0 comments on commit 515d37d

Please sign in to comment.