registry

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONSUMER = iota
	CONFIGURATOR
	ROUTER
	PROVIDER
)
View Source
const (
	DEFAULT_REGISTRY_TIMEOUT = 1 * time.Second
	ConsumerRegistryZkClient = "consumer zk registry"
)
View Source
const (
	MAX_TIMES                   = 15
	ZkEvent_Channel_Size        = 32
	ZKCLIENT_EVENT_CHANNEL_SIZE = 4
)
View Source
const (
	ServiceURLAdd = iota
	ServiceURLDel
)
View Source
const (
	ProviderRegistryZkClient = "provider zk registry"
)
View Source
const (
	REGISTRY_CONN_DELAY = 3
)

Variables

View Source
var (
	DubboNodes       = [...]string{"consumers", "configurators", "routers", "providers"}
	DubboRole        = [...]string{"consumer", "", "", "provider"}
	RegistryZkClient = "zk registry"
)
View Source
var (
	ErrServiceArrayEmpty   = jerrors.New("serviceArray empty")
	ErrServiceArrayTimeout = jerrors.New("serviceArray timeout")
)
View Source
var (
	ErrorRegistryNotFound = jerrors.New("registry not found")
)

Functions

This section is empty.

Types

type ApplicationConfig

type ApplicationConfig struct {
	Organization string `yaml:"organization"  json:"organization,omitempty"`
	Name         string `yaml:"name" json:"name,omitempty"`
	Module       string `yaml:"module" json:"module,omitempty"`
	Version      string `yaml:"version" json:"version,omitempty"`
	Owner        string `yaml:"owner" json:"owner,omitempty"`
	Environment  string `yaml:"environment" json:"environment,omitempty"`
}

func (*ApplicationConfig) ToString

func (c *ApplicationConfig) ToString() string

type DubboType

type DubboType int

func (DubboType) Role

func (t DubboType) Role() string

func (DubboType) String

func (t DubboType) String() string

type Mode

type Mode int

Mode defines the algorithm of selecting a provider from cluster

const (
	SM_BEGIN Mode = iota
	SM_Random
	SM_RoundRobin
	SM_END
)

func (Mode) String

func (s Mode) String() string

type Option

type Option func(*Options)

func ApplicationConf

func ApplicationConf(conf ApplicationConfig) Option

func BalanceMode

func BalanceMode(mode Mode) Option

func RegistryConf

func RegistryConf(conf RegistryConfig) Option

func ServiceTTL

func ServiceTTL(ttl time.Duration) Option

type Options

type Options struct {
	ApplicationConfig
	RegistryConfig // ZooKeeperServers []string
	// contains filtered or unexported fields
}

type ProviderServiceConfig

type ProviderServiceConfig struct {
	ServiceConfig
	Path    string
	Methods string
}

func (ProviderServiceConfig) ServiceEqual

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

func (ProviderServiceConfig) String

func (c ProviderServiceConfig) String() string

type Registry

type Registry interface {
	Register(conf interface{}) error
	Close()
}

for service discovery/registry

type RegistryConfig

type RegistryConfig struct {
	Address    []string      `required:"true" yaml:"address"  json:"address,omitempty"`
	UserName   string        `yaml:"user_name" json:"user_name,omitempty"`
	Password   string        `yaml:"password" json:"password,omitempty"`
	TimeoutStr string        `yaml:"timeout" default:"5s" json:"timeout,omitempty"` // unit: second
	Timeout    time.Duration `yaml:"-"  json:"-"`
}

type ServerConfig

type ServerConfig struct {
	Protocol string `required:"true",default:"dubbo" yaml:"protocol" json:"protocol,omitempty"` // codec string, jsonrpc  etc
	IP       string `yaml:"ip" json:"ip,omitempty"`
	Port     int    `required:"true" yaml:"port" json:"port,omitempty"`
}

func (*ServerConfig) Address

func (c *ServerConfig) Address() string

type ServiceConfig

type ServiceConfig struct {
	Protocol string `required:"true",default:"dubbo"  yaml:"protocol"  json:"protocol,omitempty"`
	Service  string `required:"true"  yaml:"service"  json:"service,omitempty"`
	Group    string `yaml:"group" json:"group,omitempty"`
	Version  string `yaml:"version" json:"version,omitempty"`
}

func (ServiceConfig) Key

func (c ServiceConfig) Key() string

func (ServiceConfig) ServiceEqual

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

func (ServiceConfig) String

func (c 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.ikurento.dubbo.UserProvider3
	Ip           string
	Port         string
	Timeout      time.Duration
	Version      string
	Group        string
	Query        url.Values
	Weight       int32
	PrimitiveURL string
}

func NewServiceURL

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

func (*ServiceURL) CheckMethod

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

func (*ServiceURL) ServiceConfig

func (s *ServiceURL) ServiceConfig() ServiceConfig

func (ServiceURL) String

func (s ServiceURL) String() string

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 ZkConsumerRegistry

type ZkConsumerRegistry struct {
	Options

	sync.Mutex
	// contains filtered or unexported fields
}

func NewZkConsumerRegistry

func NewZkConsumerRegistry(opts ...Option) (*ZkConsumerRegistry, error)

func (*ZkConsumerRegistry) Close

func (r *ZkConsumerRegistry) Close()

func (*ZkConsumerRegistry) Filter

func (r *ZkConsumerRegistry) Filter(s ServiceConfigIf, reqID int64) (*ServiceURL, error)

func (*ZkConsumerRegistry) Register

func (r *ZkConsumerRegistry) Register(conf ServiceConfig) error

type ZkProviderRegistry

type ZkProviderRegistry struct {
	Options

	sync.Mutex // lock for client + services
	// contains filtered or unexported fields
}

func NewZkProviderRegistry

func NewZkProviderRegistry(opts ...Option) (*ZkProviderRegistry, error)

func (*ZkProviderRegistry) Close

func (r *ZkProviderRegistry) Close()

func (*ZkProviderRegistry) Register

func (r *ZkProviderRegistry) Register(c interface{}) error

Jump to

Keyboard shortcuts

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