sdp

package
v0.0.0-...-6a6dcdd Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const RedisAppKey = "sdp:apps:%s"

Variables

View Source
var Chan chan Request

Functions

func Init

func Init()

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(conf Conf) *Client

func (*Client) Discovery

func (m *Client) Discovery(app string) (host string, port int)

Discovery 查找可用服务

func (*Client) Register

func (m *Client) Register(app string, host string, port int)

Register 注册服务 app、host、port: 服务信息

func (*Client) SendMsg

func (m *Client) SendMsg(targetApp string, targetHost string, targetPort int, msg string) (err error)

SendMsg app: 必选,指定应用 host/port: 可选,指定服务器;空则向所有实例的应用发送消息

type Conf

type Conf struct {
	SysmainUrl string //sysmain地址
	ClientRoot string //client跟路由
	Secret     string //接口秘钥
	PingSecond int    //ping间隔
	Redis      struct {
		Host string
		Pass string
	} //redis非空,则ping/discovery就都会使用Redis,无Redis配置则通过接口获取
}

type Instance

type Instance struct {
	Host   string `json:"h"`
	Port   int    `json:"p"`
	Weight int    `json:"w,omitempty"` //权重
	Time   int64  `json:"t"`           //上次ping的时间
}

type Request

type Request struct {
	App  string  `json:"app" form:"app"`
	Host string  `json:"host" form:"host"`
	Port int     `json:"port" form:"port"`
	Cpu  float32 `json:"cpu" form:"cpu"`
	Memo float32 `json:"memo" form:"memo"`
}

Jump to

Keyboard shortcuts

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