service_infra

package
v0.4.19 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterServiceInfra

func RegisterServiceInfra(name string, creator infraCreator)

Types

type ChangedInfo

type ChangedInfo struct {
	Hosts []string
}

ChangedInfo service changed info

type ChangedType

type ChangedType int

ChangedType service info type

const (
	ServiceAdd ChangedType = iota
	ServiceChange
	ServiceDelete
)

type IServiceInfra

type IServiceInfra interface {
	// Init will init service infra module with custom option
	Init(...Option) error
	// Start service-infra module, connect to soa center
	Start() error
	// Stop disconnect to soa center, remove all service cache
	Stop() error
	// Tick tick func called by logic goroutine
	Tick()
	//FindServiceAsync will find service asynchronous
	//It will call callback function which added by AddListener
	FindServiceAsync(svsName string) error
	// FindService will find service from soa system by name
	FindService(svsName string) (*ServiceInfo, error)
	// RegisterService register service to soa
	RegisterService(svsName string, info *ServiceInfo) error
	// UnRegisterService unregister service
	UnRegisterService(svsName string, info *ServiceInfo) error
	//AddListener will store service changed callback by service name
	AddListener(handle ServiceEventHandle) error
	//DelListener del server event listener
	DelListener() error
	//IsConnected is connected  to soa center
	IsConnected() bool
}

IServiceInfra service finder and register interface

func CreateServiceInfra

func CreateServiceInfra(name string) IServiceInfra

type Option added in v0.4.8

type Option func(*Options)

func WithAppendHost added in v0.4.8

func WithAppendHost(host string) Option

func WithHosts added in v0.4.8

func WithHosts(hosts []string) Option

func WithPrefix added in v0.4.8

func WithPrefix(prefix string) Option

type Options added in v0.4.8

type Options struct {
	//Prefix 路径前缀,支持多层级的路径
	Prefix string `yaml:"prefix"`
	//Auth 鉴权接口,预留
	Auth string
	//Hosts 发现用地址
	Hosts []string `yaml:"hosts"`
}

Options zookeeper模块配置

func (*Options) PreProcess added in v0.4.8

func (o *Options) PreProcess()

type ServiceEventHandle

type ServiceEventHandle func(svsName string, eventType ChangedType, changeInfo *ChangedInfo, err error)

ServiceEventHandle service changed handler

type ServiceInfo

type ServiceInfo struct {
	Hosts []string // ip:port
}

ServiceInfo service info

func MakeServiceInfo

func MakeServiceInfo(hosts []string) *ServiceInfo

MakeServiceInfo create service info with service list

Jump to

Keyboard shortcuts

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