-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
134 changed files
with
23,875 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.