dist

package
v0.1.25 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: LGPL-2.1 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Name      = plugin.Name
	Using     = plugin.Using
	Install   = plugin.Install
	Uninstall = plugin.Uninstall
)

Functions

func GetFutures

func GetFutures(servCtx service.Context) concurrent.IFutures

GetFutures 获取异步模型Future控制器

func MakeBalanceAddr added in v0.1.25

func MakeBalanceAddr(servCtx service.Context, serviceName string) string

MakeBalanceAddr 创建服务负载均衡地址

func MakeBroadcastAddr added in v0.1.25

func MakeBroadcastAddr(servCtx service.Context, serviceName string) string

MakeBroadcastAddr 创建服务广播地址

func MakeNodeAddr added in v0.1.25

func MakeNodeAddr(servCtx service.Context, nodeId string) (string, error)

MakeNodeAddr 创建服务节点地址

func SendMsg

func SendMsg(servCtx service.Context, dst string, msg gap.Msg) error

SendMsg 发送消息

Types

type Address

type Address struct {
	Domain               string // 主域
	BroadcastSubdomain   string // 广播地址子域
	BalanceSubdomain     string // 负载均衡地址子域
	NodeSubdomain        string // 服务节点地址子域
	GlobalBroadcastAddr  string // 全局广播地址
	GlobalBalanceAddr    string // 全局负载均衡地址
	ServiceBroadcastAddr string // 服务广播地址
	ServiceBalanceAddr   string // 服务负载均衡地址
	LocalAddr            string // 本服务节点地址
}

Address 地址信息

func GetAddress

func GetAddress(servCtx service.Context) Address

GetAddress 获取地址信息

type DistServiceOptions added in v0.1.22

type DistServiceOptions struct {
	Version           string            // 服务版本号
	Meta              map[string]string // 服务元数据,以键值对的形式保存附加信息
	Domain            string            // 服务地址域
	RefreshInterval   time.Duration     // 服务信息刷新间隔
	FutureTimeout     time.Duration     // 异步模型Future超时时间
	DecoderMsgCreator gap.IMsgCreator   // 消息包解码器的消息构建器
	RecvMsgHandler    RecvMsgHandler    // 接收消息的处理器(优先级低于监控器)
}

DistServiceOptions 所有选项

type IDistService added in v0.1.22

type IDistService interface {
	// GetAddress 获取地址信息
	GetAddress() Address
	// GetFutures 获取异步模型Future控制器
	GetFutures() concurrent.IFutures
	// MakeBroadcastAddr 创建服务广播地址
	MakeBroadcastAddr(service string) string
	// MakeBalanceAddr 创建服务负载均衡地址
	MakeBalanceAddr(service string) string
	// MakeNodeAddr 创建服务节点地址
	MakeNodeAddr(node string) (string, error)
	// SendMsg 发送消息
	SendMsg(dst string, msg gap.Msg) error
	// WatchMsg 监听消息(优先级高)
	WatchMsg(ctx context.Context, handler RecvMsgHandler) IWatcher
}

IDistService 分布式服务支持

type IWatcher

type IWatcher interface {
	context.Context
	Stop() <-chan struct{}
}

IWatcher 监听器

func WatchMsg

func WatchMsg(servCtx service.Context, ctx context.Context, handler RecvMsgHandler) IWatcher

WatchMsg 监听消息

type Option

type Option struct{}

Option 所有选项设置器

func (Option) DecoderMsgCreator

func (Option) DecoderMsgCreator(mc gap.IMsgCreator) option.Setting[DistServiceOptions]

DecoderMsgCreator 消息包解码器的消息构建器

func (Option) Default

Default 默认值

func (Option) Domain

func (Option) Domain(domain string) option.Setting[DistServiceOptions]

Domain 服务地址域

func (Option) FutureTimeout

FutureTimeout 异步模型Future超时时间

func (Option) Meta added in v0.1.21

Meta 服务元数据,以键值对的形式保存附加信息

func (Option) RecvMsgHandler

func (Option) RecvMsgHandler(handler RecvMsgHandler) option.Setting[DistServiceOptions]

RecvMsgHandler 接收消息的处理器

func (Option) RefreshInterval

func (Option) RefreshInterval(d time.Duration) option.Setting[DistServiceOptions]

RefreshInterval 服务信息刷新间隔

func (Option) Version

func (Option) Version(version string) option.Setting[DistServiceOptions]

Version 服务版本号

type RecvMsgHandler

type RecvMsgHandler = generic.DelegateFunc2[string, gap.MsgPacket, error] // 接收消息的处理器

Jump to

Keyboard shortcuts

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