forked from Terry-Mao/bfs
-
Notifications
You must be signed in to change notification settings - Fork 0
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
7 changed files
with
97 additions
and
112 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 |
---|---|---|
@@ -1,72 +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 | ||
Framed bool | ||
} | ||
|
||
// 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 | ||
} | ||
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 | ||
} |
Binary file not shown.
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 |
---|---|---|
|
@@ -58,5 +58,3 @@ MaxIdle = 100 | |
|
||
# Note that you must specify a number here. | ||
Timeout = "1s" | ||
|
||
Framed = false |
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
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
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
Binary file not shown.