rdiscovery

package module
v0.0.0-...-6241a09 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: MIT Imports: 3 Imported by: 1

README

rdiscovery

a sample service register&discovery

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyRegitered = errors.New("same service name is already registered")
	ErrClose            = errors.New("register is close")
)

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Get(service string) ([]*ServiceNode, bool)
	Set(service string, nodes []*ServiceNode)
	Del(service string)
}

type Options

type Options struct {
	CheckInterval time.Duration
	CheckTimeout  time.Duration
	CheckAddress  string
}

type RCache

type RCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewRCache

func NewRCache() *RCache

func (*RCache) Del

func (c *RCache) Del(service string)

func (*RCache) Get

func (c *RCache) Get(service string) ([]*ServiceNode, bool)

func (*RCache) GetAll

func (c *RCache) GetAll() map[string][]*ServiceNode

func (*RCache) Set

func (c *RCache) Set(service string, nodes []*ServiceNode)

type Register

type Register interface {
	Register(Node *ServiceNode, opt *Options) error
	Deregister(Node *ServiceNode) error
	GetService(service string) ([]*ServiceNode, error)
	Close()
}

type ServiceNode

type ServiceNode struct {
	Name    string
	ID      string
	Address string
	Port    int
}

Directories

Path Synopsis
consul module

Jump to

Keyboard shortcuts

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