Documentation ¶
Index ¶
- Constants
- Variables
- func Deregister(s *Service) error
- func Register(s *Service, opts ...RegisterOption) error
- func String() string
- type Endpoint
- type Node
- type Option
- type Options
- type RedisService
- type RegisterOption
- type RegisterOptions
- type Registry
- type Result
- type Service
- type Value
- type WatchOption
- type WatchOptions
- type Watcher
Constants ¶
View Source
const ( Del = "DEL" SRem = "SREM" Keys = "KEYS" SAdd = "SADD" Set = "SET" Get = "GET" SMembers = "SMEMBERS" )
View Source
const ModuleInfoRedisKey redisKey = "gserver:module:info"
View Source
const RegisterRedisKey redisKey = "gserver:modules"
Variables ¶
View Source
var ( DefaultRegistry = newRedisRegistry() ErrNotFound = errors.New("not found") )
Functions ¶
func Register ¶
func Register(s *Service, opts ...RegisterOption) error
Register a service node. Additionally supply options such as TTL.
Types ¶
type RedisService ¶
type RegisterOption ¶
type RegisterOption func(*RegisterOptions)
func RegisterTTL ¶
func RegisterTTL(t time.Duration) RegisterOption
type Registry ¶
type Registry interface { Options() Options Register(*Service, ...RegisterOption) error Deregister(*Service) error GetService(string) ([]*Service, error) ListServices() ([]*Service, error) String() string Clean(typeName string) error Check(string) bool }
The registry provides an interface for service discovery and an abstraction over varying implementations {consul, etcd, zookeeper, ...}
func NewConsulRegistry ¶
func NewRedisRegistry ¶
type Result ¶
Result is returned by a call to Next on the watcher. Actions can be create, update, delete
type Service ¶
type Service struct { Name string `json:"name"` Version string `json:"version"` Metadata map[string]string `json:"metadata"` Endpoints []*Endpoint `json:"endpoints"` Nodes []*Node `json:"nodes"` ID string `json:"id"` Address string `json:"address"` }
func GetService ¶
Retrieve a service. A slice is returned since we separate Name/Version.
func ListServices ¶
List the services. Only returns service names
type WatchOption ¶
type WatchOption func(*WatchOptions)
type WatchOptions ¶
Specify a service to watch If blank, the watch is for all services
Click to show internal directories.
Click to hide internal directories.