registry

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2016 License: Apache-2.0 Imports: 8 Imported by: 4

Documentation

Index

Constants

View Source
const (
	ServiceURLAdd = iota
	ServiceURLDel
	ServiceURLUpdate
)
View Source
const (
	REGISTRY_CONN_DELAY = 3 // watchDir中使用,防止不断地对zk重连
)

Variables

View Source
var (
	ErrorRegistryNotFound = errors.New("registry not found")
)

Functions

This section is empty.

Types

type Option

type Option func(*Options)

Option used to initialise the client

func ApplicationConf

func ApplicationConf(conf common.ApplicationConfig) Option

func Context

func Context(ctx context.Context) Option

func RegistryConf

func RegistryConf(conf RegistryConfig) Option

type Options

type Options struct {
	common.ApplicationConfig
	RegistryConfig

	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context
}

type ProviderServiceConfig

type ProviderServiceConfig struct {
	ServiceConfig
	Path    string
	Methods string
}

func (ProviderServiceConfig) ServiceEqual

func (this ProviderServiceConfig) ServiceEqual(url *ServiceURL) bool

func (ProviderServiceConfig) String

func (this ProviderServiceConfig) String() string

type Registry

type Registry interface {
	// Register(conf ServiceConfig) error
	Register(conf interface{}) error
	GetService(string) ([]*ServiceURL, error)
	ListServices() ([]*ServiceURL, error)
	Watch() (Watcher, error)
	Close()
	String() string
}

The registry provides an interface for service discovery and an abstraction over varying implementations {consul, etcd, zookeeper, ...}

type RegistryConfig

type RegistryConfig struct {
	Address  []string `required:"true"`
	UserName string
	Password string
	Timeout  int `default:"5"` // unit: second
}

type Result

type Result ServiceURLEvent

Result is returned by a call to Next on the watcher. Actions can be create, update, delete

func (Result) String

func (r Result) String() string

type ServerConfig

type ServerConfig struct {
	Protocol string `required:"true",default:"dubbo"` // codec string, jsonrpc etc
	IP       string
	Port     int `required:"true"`
}

func (*ServerConfig) Address

func (this *ServerConfig) Address() string

type ServiceConfig

type ServiceConfig struct {
	Protocol string `required:"true",default:"dubbo"` // codec string, jsonrpc etc
	// func (this *consumerZookeeperRegistry) Register(conf ServiceConfig) 函数用到了Service
	// "/dubbo/com.ofpay.demo.api.UserProvider/providers" Service指代中间这一部分,目前假设它与interface相同
	Service string `required:"true"`
	Group   string
	Version string
}

func (*ServiceConfig) ServiceConfig

func (this *ServiceConfig) ServiceConfig() *ServiceConfig

func (ServiceConfig) ServiceEqual

func (this ServiceConfig) ServiceEqual(url *ServiceURL) bool

目前不支持一个service的多个协议的使用,将来如果要支持,关键点就是修改这个函数

func (ServiceConfig) String

func (this ServiceConfig) String() string

type ServiceConfigIf

type ServiceConfigIf interface {
	String() string
	ServiceEqual(url *ServiceURL) bool
}

type ServiceURL

type ServiceURL struct {
	Protocol     string
	Location     string // ip+port
	Path         string // like  /com.qianmi.dubbo.UserProvider
	Ip           string
	Port         string
	Version      string
	Group        string
	Query        url.Values
	Weight       int32
	PrimitiveURL string
}

func NewServiceURL

func NewServiceURL(urlString string) (*ServiceURL, error)

func (*ServiceURL) CheckMethod

func (this *ServiceURL) CheckMethod(method string) bool

type ServiceURLEvent

type ServiceURLEvent struct {
	Action  ServiceURLEventType
	Service *ServiceURL
}

func (ServiceURLEvent) String

func (e ServiceURLEvent) String() string

type ServiceURLEventType

type ServiceURLEventType int

func (ServiceURLEventType) String

func (t ServiceURLEventType) String() string

type Watcher

type Watcher interface {
	// Next is a blocking call
	Next() (*Result, error)
	Valid() bool // 检查watcher与registry连接是否正常
	Stop()
}

Watcher is an interface that returns updates about services within the registry.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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