Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
// DefaultPrefix is the key prefix in etcd
DefaultPrefix = "iget/service/grpc"
)
Functions ¶
This section is empty.
Types ¶
type EtcdPublisher ¶
type EtcdPublisher struct { Logger util.Logger `inject:"logger.default"` // should be in format as iger/service/grpc/{ServiceName} Prefix string TTL time.Duration Client *client.Client Kapi client.KeysAPI }
EtcdPublisher publish sevice info to etcd
func NewEtcdPublisher ¶
func NewEtcdPublisher(hosts []string, ttl int) *EtcdPublisher
NewEtcdPublisher returns the publisher which refresh every ttl seconds and has DefaultPrefix
func NewEtcdPublisherWithPrefix ¶
func NewEtcdPublisherWithPrefix(hosts []string, prefix string, ttl int) *EtcdPublisher
NewEtcdPublisherWithPrefix returns the publisher which refreshes every ttl seconds and has prefix
func (*EtcdPublisher) Heartbeat ¶
func (ep *EtcdPublisher) Heartbeat(service *Service)
Heartbeat blocks and refresh TTL every {ttl} seconds until the service is Unregistered
func (*EtcdPublisher) Register ¶
func (ep *EtcdPublisher) Register(service *Service) error
Register stores the info of service at registry, and keep it, refresh it
func (*EtcdPublisher) Unregister ¶
func (ep *EtcdPublisher) Unregister(service *Service) error
Unregister removes the Publisher.FullKey at registry
type EtcdResolver ¶
type EtcdResolver struct { ServiceName string // service name to resolve // contains filtered or unexported fields }
EtcdResolver is the implementaion of grpc.naming.Resolver
func NewResolver ¶
func NewResolver(serviceName, prefix string) *EtcdResolver
NewResolver return EtcdResolver with service name
func (*EtcdResolver) Resolve ¶
func (er *EtcdResolver) Resolve(target string) (naming.Watcher, error)
Resolve to resolve the service from etcd, target is the dial address of etcd target example: "http://127.0.0.1:2379,http://127.0.0.1:12379,http://127.0.0.1:22379"
type EtcdWatcher ¶
type EtcdWatcher struct {
// contains filtered or unexported fields
}
EtcdWatcher is the implementaion of grpc.naming.Watcher
type Publisher ¶
type Publisher interface { Register(*Service) error Unregister(*Service) error HeartBeat(*Service) }
Publisher is able to register and unregister service to registry