Documentation ¶
Index ¶
- Constants
- Variables
- func AssertTrue(b bool)
- func AssertTruef(b bool, format string, args ...interface{})
- func Check(err error)
- func Check2(_ interface{}, err error)
- func Checkf(err error, format string, args ...interface{})
- func CreatePidfile(pidFile string) error
- func EncodeBytesAscending(b []byte, data []byte) []byte
- func EncodeStringAscending(b []byte, s string) []byte
- func EncodeUint64Ascending(b []byte, v uint64) []byte
- func ErrorIf(err error, msg string, data ...interface{})
- func Errorf(format string, args ...interface{}) error
- func Fatal(v ...interface{})
- func FatalIf(err error, msg string, data ...interface{})
- func Fatalf(format string, v ...interface{})
- func Fatalln(v ...interface{})
- func GenerateRandomId() []byte
- func GenerateRandomIdByLength(length int) []byte
- func GenerateRandomNumberId() []byte
- func GetAndCreateDataDir(baseDir string, id uint64, isMon bool) (string, error)
- func GetDataDir(baseDir string, id uint64, isMon bool) (string, error)
- func HashKey(key string) uint32
- func Panic(level int, v ...interface{})
- func Panicf(level int, format string, v ...interface{})
- func Panicln(level int, v ...interface{})
- func Print(level int, v ...interface{})
- func Printf(level int, format string, v ...interface{})
- func Println(level int, v ...interface{})
- func RemovePidfile(pidFile string)
- func SecureCompare(given string, actual string) bool
- func StackTrace(str string, all bool)
- func Ternary(IF bool, THEN interface{}, ELSE interface{}) interface{}
- func Wrap(err error) error
- func Wrapf(err error, format string, args ...interface{}) error
- func WritePid(pidfile string) error
- type Config
- type Notifier
- type RaftConfig
- type SafeMap
- func (m *SafeMap) Check(k interface{}) bool
- func (m *SafeMap) Delete(k interface{})
- func (m *SafeMap) Get(k interface{}) interface{}
- func (m *SafeMap) Items() map[interface{}]interface{}
- func (m *SafeMap) LoadOrStore(k interface{}, v interface{}) (actual interface{}, loaded bool)
- func (m *SafeMap) Set(k interface{}, v interface{}) bool
- type SafeMutex
- type SafeWait
Constants ¶
const ( // The default port for HTTP-for-humans. DefaultHTTPPort = "8080" // NetworkTimeout is the timeout used for network operations. NetworkTimeout = 3 * time.Second )
Variables ¶
var DefaultConfig = Config{ LogPath: "/var/log/nentropy/nentropy.log", PanicLogPath: "/var/log/nentropy/panic.log", PidFile: "/var/run/nentropy/nentropy.pid", DebugMode: false, LogLevel: 10, WALDir: "w", JoinMon: false, NumPendingProposals: 2000, Tracing: 0.0, Monitors: "", RaftId: 1, MaxPendingCount: 1000, MemberBindPort: 7946, JoinMemberAddr: "", NodeType: "osd", Zipkin: "", }
var Logger *log.Logger
var NumericTable = []byte("0123456789")
Functions ¶
func AssertTrue ¶
func AssertTrue(b bool)
AssertTrue asserts that b is true. Otherwise, it would log fatal.
func AssertTruef ¶
AssertTruef is AssertTrue with extra info.
func Check2 ¶
func Check2(_ interface{}, err error)
Check2 acts as convenience wrapper around Check, using the 2nd argument as error.
func CreatePidfile ¶
func EncodeBytesAscending ¶
EncodeBytesAscending encodes the []byte value using an escape-based encoding. The encoded value is terminated with the sequence "\x00\x01" which is guaranteed to not occur elsewhere in the encoded value. The encoded bytes are append to the supplied buffer and the resulting buffer is returned.
func EncodeStringAscending ¶
EncodeStringAscending encodes the string value using an escape-based encoding. See EncodeBytes for details. The encoded bytes are append to the supplied buffer and the resulting buffer is returned.
func EncodeUint64Ascending ¶
EncodeUint64Ascending encodes the uint64 value using a big-endian 8 byte representation. The bytes are appended to the supplied buffer and the final buffer is returned.
func Fatal ¶
func Fatal(v ...interface{})
Fatal is equivalent to l.Print() followed by a call to os.Exit(1).
func Fatalf ¶
func Fatalf(format string, v ...interface{})
Fatalf is equivalent to l.Printf() followed by a call to os.Exit(1).
func Fatalln ¶
func Fatalln(v ...interface{})
Fatalln is equivalent to l.Println() followed by a call to os.Exit(1).
func GenerateRandomId ¶
func GenerateRandomId() []byte
func GenerateRandomNumberId ¶
func GenerateRandomNumberId() []byte
func GetAndCreateDataDir ¶
func Panic ¶
func Panic(level int, v ...interface{})
Panic is equivalent to l.Print() followed by a call to panic().
func Panicln ¶
func Panicln(level int, v ...interface{})
Panicln is equivalent to l.Println() followed by a call to panic().
func Print ¶
func Print(level int, v ...interface{})
Print calls l.Output to print to the logger. Arguments are handled in the manner of fmt.Print.
func Printf ¶
Printf calls l.Output to print to the logger. Arguments are handled in the manner of fmt.Printf.
func Println ¶
func Println(level int, v ...interface{})
Println calls l.Output to print to the logger. Arguments are handled in the manner of fmt.Println.
func RemovePidfile ¶
func RemovePidfile(pidFile string)
func SecureCompare ¶
From https://github.com/codegangsta/martini-contrib/blob/master/auth/util.go SecureCompare performs a constant time compare of two strings to limit timing attacks.
func StackTrace ¶
Types ¶
type Config ¶
type Config struct { LogPath string PanicLogPath string PidFile string DebugMode bool LogLevel int //1-20 WALDir string JoinMon bool NumPendingProposals int Tracing float64 Monitors string RaftId uint64 MaxPendingCount uint64 MemberBindPort int JoinMemberAddr string NodeID int NodeType string BaseDir string // AdvertiseAddr is the address advertised by the server to other nodes // in the cluster. It should be reachable by all other nodes and should // route to an interface that Addr is listening on. AdvertiseAddr string AdvertiseIp string HTTPAddr string Zipkin string }
var CONFIG Config
func (*Config) InitConfig ¶
func (c *Config) InitConfig()
type Notifier ¶
type Notifier struct {
// contains filtered or unexported fields
}
func NewNotifier ¶
func NewNotifier() *Notifier
type RaftConfig ¶
type RaftConfig struct { // RaftTickInterval is the resolution of the Raft timer. RaftTickInterval time.Duration // RaftElectionTimeoutTicks is the number of raft ticks before the // previous election expires. This value is inherited by individual stores // unless overridden. RaftElectionTimeoutTicks int // RangeLeaseRaftElectionTimeoutMultiplier specifies what multiple the leader // lease active duration should be of the raft election timeout. RangeLeaseRaftElectionTimeoutMultiplier float64 }
RaftConfig holds raft tuning parameters.
func (*RaftConfig) SetDefaults ¶
func (cfg *RaftConfig) SetDefaults()
SetDefaults initializes unset fields.
type SafeMap ¶
type SafeMap struct {
// contains filtered or unexported fields
}
func (*SafeMap) Get ¶
func (m *SafeMap) Get(k interface{}) interface{}
Get from maps return the k's value
func (*SafeMap) Items ¶
func (m *SafeMap) Items() map[interface{}]interface{}
Items returns all items in safemap.
func (*SafeMap) LoadOrStore ¶
Maps the given key and value. Returns false if the key is already in the map and changes nothing.
type SafeMutex ¶
type SafeMutex struct {
// contains filtered or unexported fields
}
SafeLock can be used in place of sync.RWMutex
func (*SafeMutex) AssertLock ¶
func (s *SafeMutex) AssertLock()
func (*SafeMutex) AssertRLock ¶
func (s *SafeMutex) AssertRLock()