registry

package
v0.0.0-...-c188a41 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SERVICE_PREFIX string = "/servers/"
)

Variables

This section is empty.

Functions

func AddWatcher

func AddWatcher(watcher chan bool)

func Deregister

func Deregister() error

func Init

func Init(opts Options)

func ListServices

func ListServices() ([]string, error)

func NotifyWatcher

func NotifyWatcher()

func Register

func Register() error

Types

type Node

type Node struct {
	Id          string            `json:"id"`
	ServiceName string            `json:"serviceName"`
	Path        string            `json:"path"`
	Ip          string            `json:"ip"`
	Port        int               `json:"port"`
	Info        map[string]string `json:"info"`
}

func (*Node) Addr

func (n *Node) Addr() string

func (*Node) String

func (n *Node) String() string

type Options

type Options struct {
	Host        string `yaml:"host"`
	User        string `yaml:"user"`
	Pwd         string `yaml:"pwd"`
	Ip          string `yaml:"ip"`
	ServiceName string `yaml:"serviceName"`
	Weight      int    `yaml:"weight"`
	Enable      bool   `yaml:"enable"`
	Port        int    `yaml:"port"`
	Timeout     int64  `yaml:"timeout"`
}

type Registry

type Registry interface {
	Init(Options) error
	Register() error
	Deregister() error
	GetService(name string) (Service, error)
	ListServices() ([]string, error)
}
var (
	ServiceRegistry    *Registry
	InvokeInitRegistry func(opts Options) (Registry, error)
)

type Service

type Service struct {
	Name  string  `json:"name"`
	Nodes []*Node `json:"nodes"`
}

func GetService

func GetService(name string) (Service, error)

Jump to

Keyboard shortcuts

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