registry

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: Apache-2.0 Imports: 16 Imported by: 2

Documentation

Overview

Package registry is default registry implements.

Index

Constants

View Source
const (
	DefaultSnapshotInterval  = 10 * time.Second
	DefaultHeartbeatInterval = 10 * 1000 //ms
	DefaultTimeout           = 3 * 1000  //ms
	DefaultSnapshotDir       = "./snapshot"
)
View Source
const (
	Direct = "direct"
	Local  = "local"
	Consul = "consul"
	ZK     = "zookeeper"
	Mesh   = "mesh"
)

ext name

Variables

This section is empty.

Functions

func CheckSnapshotDir

func CheckSnapshotDir()

func GetNodeKey

func GetNodeKey(url *motan.URL) string

func GetSnapshotConf

func GetSnapshotConf() *motan.SnapshotConf

func GetSubKey

func GetSubKey(url *motan.URL) string

func IsAgent

func IsAgent(url *motan.URL) bool

func JSONString

func JSONString(v interface{}) string

func RegistDefaultRegistry

func RegistDefaultRegistry(extFactory motan.ExtensionFactory)

func SaveSnapshot

func SaveSnapshot(registry string, nodeKey string, nodes ServiceNode)

func SetSnapshotConf

func SetSnapshotConf(snapshotInterval time.Duration, snapshotDir string)

func StringToSliceByte

func StringToSliceByte(s string) []byte

Types

type ConsulRegistry

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

ConsulRegistry TODO implement

func (*ConsulRegistry) Available

func (v *ConsulRegistry) Available(serverURL *motan.URL)

func (*ConsulRegistry) Discover

func (v *ConsulRegistry) Discover(url *motan.URL) []*motan.URL

func (*ConsulRegistry) GetName

func (v *ConsulRegistry) GetName() string

func (*ConsulRegistry) GetRegisteredServices

func (v *ConsulRegistry) GetRegisteredServices() []*motan.URL

func (*ConsulRegistry) GetURL

func (v *ConsulRegistry) GetURL() *motan.URL

func (*ConsulRegistry) Initialize

func (v *ConsulRegistry) Initialize()

func (*ConsulRegistry) Register

func (v *ConsulRegistry) Register(serverURL *motan.URL)

func (*ConsulRegistry) SetURL

func (v *ConsulRegistry) SetURL(url *motan.URL)

func (*ConsulRegistry) StartSnapshot

func (v *ConsulRegistry) StartSnapshot(conf *motan.SnapshotConf)

func (*ConsulRegistry) Subscribe

func (v *ConsulRegistry) Subscribe(url *motan.URL, listener motan.NotifyListener)

func (*ConsulRegistry) UnRegister

func (v *ConsulRegistry) UnRegister(serverURL *motan.URL)

func (*ConsulRegistry) Unavailable

func (v *ConsulRegistry) Unavailable(serverURL *motan.URL)

func (*ConsulRegistry) Unsubscribe

func (v *ConsulRegistry) Unsubscribe(url *motan.URL, listener motan.NotifyListener)

type DirectRegistry

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

func (*DirectRegistry) Available

func (d *DirectRegistry) Available(serverURL *motan.URL)

func (*DirectRegistry) Discover

func (d *DirectRegistry) Discover(url *motan.URL) []*motan.URL

func (*DirectRegistry) GetName

func (d *DirectRegistry) GetName() string

func (*DirectRegistry) GetRegisteredServices

func (d *DirectRegistry) GetRegisteredServices() []*motan.URL

func (*DirectRegistry) GetURL

func (d *DirectRegistry) GetURL() *motan.URL

func (*DirectRegistry) InitRegistry

func (d *DirectRegistry) InitRegistry()

func (*DirectRegistry) Register

func (d *DirectRegistry) Register(serverURL *motan.URL)

func (*DirectRegistry) SetURL

func (d *DirectRegistry) SetURL(url *motan.URL)

func (*DirectRegistry) StartSnapshot

func (d *DirectRegistry) StartSnapshot(conf *motan.SnapshotConf)

func (*DirectRegistry) Subscribe

func (d *DirectRegistry) Subscribe(url *motan.URL, listener motan.NotifyListener)

func (*DirectRegistry) UnRegister

func (d *DirectRegistry) UnRegister(serverURL *motan.URL)

func (*DirectRegistry) Unavailable

func (d *DirectRegistry) Unavailable(serverURL *motan.URL)

func (*DirectRegistry) Unsubscribe

func (d *DirectRegistry) Unsubscribe(url *motan.URL, listener motan.NotifyListener)

type LocalRegistry

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

func (*LocalRegistry) Available

func (d *LocalRegistry) Available(serverURL *motan.URL)

func (*LocalRegistry) Discover

func (d *LocalRegistry) Discover(url *motan.URL) []*motan.URL

func (*LocalRegistry) GetName

func (d *LocalRegistry) GetName() string

func (*LocalRegistry) GetRegisteredServices

func (d *LocalRegistry) GetRegisteredServices() []*motan.URL

func (*LocalRegistry) GetURL

func (d *LocalRegistry) GetURL() *motan.URL

func (*LocalRegistry) InitRegistry

func (d *LocalRegistry) InitRegistry()

func (*LocalRegistry) Register

func (d *LocalRegistry) Register(serverURL *motan.URL)

func (*LocalRegistry) SetURL

func (d *LocalRegistry) SetURL(url *motan.URL)

func (*LocalRegistry) StartSnapshot

func (d *LocalRegistry) StartSnapshot(conf *motan.SnapshotConf)

func (*LocalRegistry) Subscribe

func (d *LocalRegistry) Subscribe(url *motan.URL, listener motan.NotifyListener)

func (*LocalRegistry) UnRegister

func (d *LocalRegistry) UnRegister(serverURL *motan.URL)

func (*LocalRegistry) Unavailable

func (d *LocalRegistry) Unavailable(serverURL *motan.URL)

func (*LocalRegistry) Unsubscribe

func (d *LocalRegistry) Unsubscribe(url *motan.URL, listener motan.NotifyListener)

type MeshRegistry

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

func (*MeshRegistry) Available

func (r *MeshRegistry) Available(serverURL *motan.URL)

func (*MeshRegistry) Discover

func (r *MeshRegistry) Discover(url *motan.URL) []*motan.URL

func (*MeshRegistry) GetName

func (r *MeshRegistry) GetName() string

func (*MeshRegistry) GetRegisteredServices

func (r *MeshRegistry) GetRegisteredServices() []*motan.URL

func (*MeshRegistry) GetURL

func (r *MeshRegistry) GetURL() *motan.URL

func (*MeshRegistry) Initialize

func (r *MeshRegistry) Initialize()

func (*MeshRegistry) Register

func (r *MeshRegistry) Register(url *motan.URL)

func (*MeshRegistry) SetURL

func (r *MeshRegistry) SetURL(url *motan.URL)

func (*MeshRegistry) StartSnapshot

func (r *MeshRegistry) StartSnapshot(conf *motan.SnapshotConf)

func (*MeshRegistry) Subscribe

func (r *MeshRegistry) Subscribe(url *motan.URL, listener motan.NotifyListener)

func (*MeshRegistry) UnRegister

func (r *MeshRegistry) UnRegister(url *motan.URL)

func (*MeshRegistry) Unavailable

func (r *MeshRegistry) Unavailable(serverURL *motan.URL)

func (*MeshRegistry) Unsubscribe

func (r *MeshRegistry) Unsubscribe(url *motan.URL, listener motan.NotifyListener)

type ServiceNode

type ServiceNode struct {
	Group string             `json:"group"`
	Path  string             `json:"path"`
	Nodes []SnapshotNodeInfo `json:"nodes"`
}

type SnapshotNodeInfo

type SnapshotNodeInfo struct {
	ExtInfo string `json:"extInfo"`
	Addr    string `json:"address"`
}

type ZkRegistry

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

ZkRegistry is a registry based on zookeeper implementation, containing the zookeeper configuration, all registration and subscription information.

func (*ZkRegistry) Available

func (z *ZkRegistry) Available(url *motan.URL)

Available moves unavailableServer node to server node.

func (*ZkRegistry) Discover

func (z *ZkRegistry) Discover(url *motan.URL) []*motan.URL

Discover returns all nodes of a service.

func (*ZkRegistry) DiscoverCommand

func (z *ZkRegistry) DiscoverCommand(url *motan.URL) string

DiscoverCommand returns string info on the command node.

func (*ZkRegistry) GetName

func (z *ZkRegistry) GetName() string

func (*ZkRegistry) GetRegisteredServices

func (z *ZkRegistry) GetRegisteredServices() []*motan.URL

GetRegisteredServices returns all registered services.

func (*ZkRegistry) GetURL

func (z *ZkRegistry) GetURL() *motan.URL

func (*ZkRegistry) Initialize

func (z *ZkRegistry) Initialize()

Initialize initializes all structure members and handles new session.

func (*ZkRegistry) IsAvailable

func (z *ZkRegistry) IsAvailable() bool

func (*ZkRegistry) Register

func (z *ZkRegistry) Register(url *motan.URL)

Register creates a unavailableServer node based on url.

func (*ZkRegistry) SetURL

func (z *ZkRegistry) SetURL(url *motan.URL)

func (*ZkRegistry) StartSnapshot

func (z *ZkRegistry) StartSnapshot(conf *motan.SnapshotConf)

func (*ZkRegistry) Subscribe

func (z *ZkRegistry) Subscribe(url *motan.URL, listener motan.NotifyListener)

Subscribe listens the service node using listener.

func (*ZkRegistry) SubscribeCommand

func (z *ZkRegistry) SubscribeCommand(url *motan.URL, listener motan.CommandNotifyListener)

SubscribeCommand listens the command node using listener.

func (*ZkRegistry) UnRegister

func (z *ZkRegistry) UnRegister(url *motan.URL)

UnRegister removes server node and unavailableServer node based on url.

func (*ZkRegistry) UnSubscribeCommand

func (z *ZkRegistry) UnSubscribeCommand(url *motan.URL, listener motan.CommandNotifyListener)

UnSubscribeCommand removes the listener of the command.

func (*ZkRegistry) Unavailable

func (z *ZkRegistry) Unavailable(url *motan.URL)

Unavailable moves server node to unavailableServer node.

func (*ZkRegistry) Unsubscribe

func (z *ZkRegistry) Unsubscribe(url *motan.URL, listener motan.NotifyListener)

Unsubscribe removes the listener of the service.

Jump to

Keyboard shortcuts

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