ssdr

package module
v0.0.0-...-4163832 Latest Latest
Warning

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

Go to latest
Published: May 22, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultServicePort = 80

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler func()

func (*Handler) Handler

func (h *Handler) Handler()

type MsgRegistry

type MsgRegistry struct {
	Type RegistryMsgType
	// MsgRegisterReq
	Service string
	Id      string
	Addr    string
	// MsgServiceListResp
	PushStart bool
	PushEnd   bool
	Services  ServiceListValue
	// resp
	Success bool
	Error   error
}

type Registry

type Registry struct {
	Addr        string
	ServiceList *ServiceList
	// contains filtered or unexported fields
}

func NewRegistry

func NewRegistry(addr string) *Registry

func (*Registry) Run

func (r *Registry) Run() error

type RegistryClient

type RegistryClient struct {
	RegistryAddr     string
	Conn             *websocket.Conn
	ServiceListValue ServiceListValue

	ServiceListUpdate chan ServiceListValue
	Quit              chan struct{}
	// contains filtered or unexported fields
}

func NewRegistryClient

func NewRegistryClient(addr string) *RegistryClient

func (*RegistryClient) Connect

func (ra *RegistryClient) Connect() (err error)

func (*RegistryClient) Disconnect

func (ra *RegistryClient) Disconnect()

func (*RegistryClient) QuickSubscribe

func (ra *RegistryClient) QuickSubscribe(service string, id string, addr string) (err error)

func (*RegistryClient) Register

func (ra *RegistryClient) Register(serviceName string, id string, addr string) error

func (*RegistryClient) Subscribe

func (ra *RegistryClient) Subscribe() (err error)

func (*RegistryClient) Unsubscribe

func (ra *RegistryClient) Unsubscribe() error

type RegistryMsgType

type RegistryMsgType int
const (
	MsgRegisterReq RegistryMsgType = iota
	MsgRegisterResp
	MsgServicePushReq
	MsgServicePushCancelReq
	MsgServicePushResp
	MsgCloseReq
)

type RegistryService

type RegistryService struct {
	Service string
	Id      string
	Addr    string
}

type RegistryServiceList

type RegistryServiceList map[string][]RegistryService

type Service

type Service []*ServiceNode

type ServiceList

type ServiceList struct {
	Services ServiceListValue

	OnAddService Handler
	// contains filtered or unexported fields
}

func (*ServiceList) Add

func (sl *ServiceList) Add(name string, node *ServiceNode)

func (*ServiceList) AddByMsg

func (sl *ServiceList) AddByMsg(msg MsgRegistry)

func (*ServiceList) Remove

func (sl *ServiceList) Remove(name string, node *ServiceNode)

func (*ServiceList) RemoveByMsg

func (sl *ServiceList) RemoveByMsg(msg MsgRegistry)

type ServiceListValue

type ServiceListValue map[string]Service

func (ServiceListValue) Get

func (svl ServiceListValue) Get(name string, excludeId string) Service

func (ServiceListValue) GetAddrs

func (svl ServiceListValue) GetAddrs(name string, excludeId string) []string

type ServiceNode

type ServiceNode struct {
	Id   string
	Addr string
}

type SubscribeHandler

type SubscribeHandler func(list ServiceListValue)

func (*SubscribeHandler) Handle

func (h *SubscribeHandler) Handle(list ServiceListValue)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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