discovery

package
v0.20.2 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Discovery

type Discovery interface {
	// Start to work
	Start() error
	//GetModuleServer get local watch module: types.BCS_MODULE_SCHEDULER...
	//if mesos-apiserver/k8s-apiserver module=clusterId.{module}, for examples: 10001.mesosdriver
	GetModuleServer(module string) (*registry.Service, error)
	// GetRandomServerInstance get random one instance of local cache server information
	//if mesos-apiserver/k8s-apiserver module=clusterId.{module}, for examples: 10001.mesosdriver
	GetRandomServerInstance(module string) (*registry.Node, error)
	//ListAllServer list all registed server information
	ListAllServer() ([]*registry.Service, error)
	// AddModuleWatch add new watch for specified module, Discovery will cache watched module info
	AddModuleWatch(module string) error
	// DeleteModuleWatch clean watch for specified module
	DeleteModuleWatch(module string) error
	// RegisterEventFunc register event handle function
	RegisterEventFunc(handleFunc EventHandler)
	// Stop close module discovery
	Stop()
}

Discovery grpc discovery definition, interface is designed for multiple module discovery.

func NewDiscovery

func NewDiscovery(modules []string, handler EventHandler, r registry.Registry) Discovery

NewDiscovery create micro discovery implementation @param modules, bkbcs modules define in common/types, meshmanager, logmanager, mesosdriver and etc. @param handler, event callback @param r, go-micro registry implementation

type EventHandler

type EventHandler func(module string)

EventHandler callback function when server changes

type MicroDiscovery

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

MicroDiscovery bkbcs go micro discovery implementation

func (*MicroDiscovery) AddModuleWatch

func (d *MicroDiscovery) AddModuleWatch(module string) error

AddModuleWatch add new watch for specified module, Discovery will cache watched module info @param: module, bkbcs module name, such as meshmanager, logmanager, storage etc.

func (*MicroDiscovery) DeleteModuleWatch

func (d *MicroDiscovery) DeleteModuleWatch(module string) error

DeleteModuleWatch clean watch for specified module

func (*MicroDiscovery) GetModuleServer

func (d *MicroDiscovery) GetModuleServer(module string) (*registry.Service, error)

GetModuleServer module: types.BCS_MODULE_SCHEDULER... if mesos-apiserver/k8s-apiserver module=clusterId.{module}, for examples: 10001.mesosdriver, storage

func (*MicroDiscovery) GetRandomServerInstance

func (d *MicroDiscovery) GetRandomServerInstance(module string) (*registry.Node, error)

GetRandomServerInstance get random one instance of server if mesos-apiserver/k8s-apiserver module=clusterId.{module}, for examples: 10001.mesosdriver, storage

func (*MicroDiscovery) ListAllServer

func (d *MicroDiscovery) ListAllServer() ([]*registry.Service, error)

ListAllServer list all registed server information

func (*MicroDiscovery) RegisterEventFunc

func (d *MicroDiscovery) RegisterEventFunc(handleFunc EventHandler)

RegisterEventFunc register event handle function

func (*MicroDiscovery) Start

func (d *MicroDiscovery) Start() error

Start init all necessary resource

func (*MicroDiscovery) Stop

func (d *MicroDiscovery) Stop()

Stop close discovery

Jump to

Keyboard shortcuts

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