discovery

package module
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2019 License: MIT Imports: 14 Imported by: 0

README

discovery

基于etcd服务发现的封装

Documentation

Index

Constants

View Source
const (
	RootPrefix    = "/afpro.micro.root/"
	NodePrefix    = RootPrefix + "node/"
	ServicePrefix = RootPrefix + "service/"
	ConfigPrefix  = RootPrefix + "config/"
)

Variables

View Source
var (
	LogRoot      = log.NewRoot(log.NewStdOutput())
	LogTagPrefix = "discovery"

	EtcdOpTimeout = time.Duration(5) * time.Second
	GRpcTimeout   = time.Duration(5) * time.Second
)
View Source
var (
	ErrNoServiceFound               = errors.New("no service with specified name found on cluster")
	ErrNoAvailableGrpcHostConnected = errors.New("no available grpc host connected")
	ErrInvalidIP                    = errors.New("invalid ip")
)

Functions

This section is empty.

Types

type ClientArgs added in v1.2.0

type ClientArgs struct {
	EtcdArgs
}

func (*ClientArgs) CreateGRpcClient added in v1.2.0

func (args *ClientArgs) CreateGRpcClient() (*GRpcClient, error)

type EtcdArgs added in v1.2.0

type EtcdArgs struct {
	Etcd      string `args:"name=etcd;usage=etcd endpoints, separate by ',';"`
	EndPoints []string
}

func (*EtcdArgs) SplitEndPoints added in v1.3.0

func (args *EtcdArgs) SplitEndPoints()

type FPickTTL

type FPickTTL func(size int, getTTL func(index int) int64) int
var (
	PickTTL FPickTTL = etcdDefaultPick
)

type GRpcClient

type GRpcClient struct {
	// contains filtered or unexported fields
}

func NewGRpcClient

func NewGRpcClient(etcd []string) (*GRpcClient, error)

func (*GRpcClient) Close

func (client *GRpcClient) Close() error

func (*GRpcClient) GetService

func (client *GRpcClient) GetService(name string) (*grpc.ClientConn, error)

type GRpcHost

type GRpcHost struct {
	// contains filtered or unexported fields
}

func NewGRpcHost added in v1.2.0

func NewGRpcHost(etcd []string, ip string, port uint16) *GRpcHost

func (*GRpcHost) AddService

func (s *GRpcHost) AddService(desc *grpc.ServiceDesc, impl interface{})

func (*GRpcHost) Serve

func (s *GRpcHost) Serve() error

noinspection GoUnhandledErrorResult

func (*GRpcHost) SetTimeout

func (s *GRpcHost) SetTimeout(seconds int64)

type HostArgs added in v1.2.0

type HostArgs struct {
	EtcdArgs
	IP   string `args:"name=ip;usage=host ip;"`
	Port uint   `args:"name=port;usage=host port;"`
}

func (*HostArgs) CreateGRpcHost added in v1.2.0

func (args *HostArgs) CreateGRpcHost() *GRpcHost

func (*HostArgs) SetupFirstLocalIp added in v1.2.0

func (args *HostArgs) SetupFirstLocalIp()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL