Documentation ¶
Index ¶
Constants ¶
const SpecSep = "\n"
SpecSep is the seperator for service spec.
Variables ¶
This section is empty.
Functions ¶
func ResolveMaster ¶
ResolveMaster resolves fiber/carbon master http arpc endpoint (host:port) from zookeeper. zfs://xxx/xxx/LeaderElection/$lock-file {endpoint-1\nendpoint-2}
Types ¶
type CacheResolver ¶
type CacheResolver struct {
// contains filtered or unexported fields
}
CacheResolver resolve endpoint with cache
func NewCacheResolver ¶
func NewCacheResolver(zfs string) *CacheResolver
NewCacheResolver creates a cache resolver
func (*CacheResolver) AfterCall ¶
func (r *CacheResolver) AfterCall(succ bool)
AfterCall reset cache address if failed.
func (*CacheResolver) Resolve ¶
func (r *CacheResolver) Resolve() (string, error)
Resolve resolves endpoint
type CacheResolverFactory ¶
type CacheResolverFactory struct {
// contains filtered or unexported fields
}
CacheResolverFactory manages a table of cached resolvers
func NewCacheResolverFactory ¶
func NewCacheResolverFactory() *CacheResolverFactory
NewCacheResolverFactory creates a new factory
func (*CacheResolverFactory) Get ¶
func (f *CacheResolverFactory) Get(zfs string) (*CacheResolver, error)
Get returns a cache resolver
type ElectApp ¶
type ElectApp struct { LostCh <-chan struct{} // contains filtered or unexported fields }
ElectApp is the base election app to use.
func NewElectApp ¶
NewElectApp creates a new elect app.
func (*ElectApp) GetLeader ¶
GetLeader return the leader spec. Call this function only if it's not the leader.
type ElectOptions ¶
type ElectOptions struct { Backend string Hosts []string Key string Val string ConnTimeout int LostTimeout int }
ElectOptions is the election options.
func ParseElectOptions ¶
func ParseElectOptions(urlStr string) (*ElectOptions, error)
ParseElectOptions parse election options from a url query string.
type Elector ¶
type Elector interface { GetLeader() (string, error) IsLeader() bool Elect(stopChan chan struct{}) (<-chan struct{}, error) Close() error }
Elector is the elector api.
func NewElector ¶
func NewElector(opts *ElectOptions) (Elector, error)
NewElector creates a new elector.
type NopElector ¶
type NopElector struct { }
NopElector is a test nop election implementation.
func (NopElector) Elect ¶
func (n NopElector) Elect(stopChan chan struct{}) (<-chan struct{}, error)
Elect try to elect the leader.
func (NopElector) GetLeader ¶
func (n NopElector) GetLeader() (string, error)
GetLeader get the leader spec.