service

package
v0.0.0-...-1c5b680 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidRelayMessage         = errors.New("invalid relay message")
	ErrInvalidRelayPassthroughType = errors.New("invalid relay passthrough type")
)
View Source
var (
	// 独立出来避免污染工具类的flagset
	CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
)
View Source
var (
	LinkRules []MatchRule // 互联发现规则
)

Functions

func AddRemoteService

func AddRemoteService(ses lib.Session, svcId, name string)

func Db

func Db(dbAlias string) *mysql.Client

func GetDiscoveryAddr

func GetDiscoveryAddr() string

func GetLocalSvcId

func GetLocalSvcId() string

获得本进程的服务id

func GetProcName

func GetProcName() string

获取当前服务进程名称

func GetRemoteService

func GetRemoteService(svcId string) lib.Session

根据svcid获取远程服务的会话

func GetSvcGroup

func GetSvcGroup() string

func GetSvcIndex

func GetSvcIndex() int

func GetWANIP

func GetWANIP() string

获取外网IP

func MakeLocalSvcId

func MakeLocalSvcId(svcName string) string

构造指定服务的ID

func MakeSvcId

func MakeSvcId(svcName string, svcIndex int, svcGroup string) string

构造服务ID

func ParseSvcId

func ParseSvcId(svcid string) (svcName string, svcIndex int, svcGroup string, err error)

func RemoveRemoteService

func RemoveRemoteService(ses lib.Session)

func Reply

func Reply(ev lib.Event, msg interface{})

回复event来源一个消息

func SetRemoteServiceNotify

func SetRemoteServiceNotify(mode string, callback NotifyFunc)

设置服务的通知

func StartMysql

func StartMysql()

func VisitRemoteService

func VisitRemoteService(callback func(ses lib.Session, ctx *RemoteServiceContext) bool)

遍历远程服务(已经连接到本进程)

Types

type MatchRule

type MatchRule struct {
	Target string
}

func ParseMatchRule

func ParseMatchRule(rule string) (ret []MatchRule)
	return util.WildcardPatternMatch(desc.GetMeta("SvcGroup"), rule.Target)
}

type NotifyFunc

type NotifyFunc func(ctx *RemoteServiceContext, ses lib.Session)

type RemoteServiceContext

type RemoteServiceContext struct {
	Name  string
	SvcId string
}

func SessionToContext

func SessionToContext(ses lib.Session) *RemoteServiceContext

取得其他服务器的会话对应的上下文

type SvcEventHooker

type SvcEventHooker struct {
}

服务互联消息处理

func (SvcEventHooker) OnInboundEvent

func (SvcEventHooker) OnInboundEvent(inputEvent lib.Event) (outputEvent lib.Event)

func (SvcEventHooker) OnOutboundEvent

func (SvcEventHooker) OnOutboundEvent(inputEvent lib.Event) (outputEvent lib.Event)

Jump to

Keyboard shortcuts

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