xclient

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = New(nil)

Functions

func Async added in v0.0.5

func Async(ctx context.Context, servicePath, serviceMethod string, args any) (call *client.Call, err error)

Async 异步调用,仅仅调用无返回值

func Broadcast added in v0.0.5

func Broadcast(ctx context.Context, servicePath, serviceMethod string, args, reply any) (err error)

func Call added in v0.0.5

func Call(ctx context.Context, servicePath, serviceMethod string, args, reply any) (err error)

func CallWithAddress added in v0.0.5

func CallWithAddress(address string, servicePath, serviceMethod string, args, reply any) (err error)

CallWithAddress 通过服务器地址发消息

func CallWithMetadata added in v0.0.5

func CallWithMetadata(req, res xshare.Metadata, servicePath, serviceMethod string, args, reply any) (err error)

CallWithMetadata 自定义metadata

func CallWithServerId added in v0.0.5

func CallWithServerId(ctx context.Context, sid int32, servicePath, serviceMethod string, args, reply any) (err error)

CallWithServerId 通过特定服务器ID发消息

func Close added in v0.0.5

func Close() (err error)

func Service added in v0.0.5

func Service(name string, handler ...interface{}) *registry.Service

func Start added in v0.0.5

func Start() (err error)

func XCall added in v0.0.5

func XCall(ctx context.Context, servicePath, serviceMethod string, args, reply any) (err error)

Types

type Client

type Client struct {
	Option      client.Option
	FailMode    client.FailMode
	Selector    interface{} //client.Selector OR client.SelectMode OR address(Peer2Peer MultipleServers)
	Discovery   client.ServiceDiscovery
	ServicePath string
	// contains filtered or unexported fields
}

func (*Client) Multiple added in v0.0.3

func (this *Client) Multiple(address []string, ch chan *protocol.Message) (err error)

Multiple 点对多

func (*Client) Peer2Peer added in v0.0.3

func (this *Client) Peer2Peer(address string, ch chan *protocol.Message) error

Peer2Peer 点对点

func (*Client) Registry added in v0.0.3

func (this *Client) Registry(selectMod client.SelectMode, selector client.Selector, registry Discovery, ch chan *protocol.Message) (err error)

Registry 使用注册中心

func (*Client) Start added in v0.0.3

func (this *Client) Start(discovery Discovery, ch chan *protocol.Message) (err error)

type Context added in v0.0.3

type Context struct {
	*protocol.Message
}

func (*Context) Get added in v0.0.3

func (ctx *Context) Get(key any) any

func (*Context) Metadata added in v0.0.3

func (ctx *Context) Metadata() map[string]string

func (*Context) Payload added in v0.0.3

func (ctx *Context) Payload() []byte

func (*Context) ServiceMethod added in v0.0.3

func (ctx *Context) ServiceMethod() string

func (*Context) ServicePath added in v0.0.3

func (ctx *Context) ServicePath() string

func (*Context) SetValue added in v0.0.3

func (ctx *Context) SetValue(key, val any)

func (*Context) Write added in v0.0.3

func (ctx *Context) Write(reply any) error

type Discovery

type Discovery func() (client.ServiceDiscovery, error)

Discovery 注册中心服务发现,点对点或者点对多时无需设置

type XClient

type XClient struct {
	Binder    binder.Interface
	Registry  *registry.Registry
	Discovery Discovery
	// contains filtered or unexported fields
}

func New added in v0.0.5

func New(ctx context.Context) *XClient

func (*XClient) Async added in v0.0.3

func (xc *XClient) Async(ctx context.Context, servicePath, serviceMethod string, args any) (done *client.Call, err error)

Async 异步

func (*XClient) Broadcast

func (xc *XClient) Broadcast(ctx context.Context, servicePath, serviceMethod string, args, reply any) (err error)

func (*XClient) Call

func (xc *XClient) Call(ctx context.Context, servicePath, serviceMethod string, args, reply any) (err error)

func (*XClient) CallWithMetadata added in v0.0.5

func (xc *XClient) CallWithMetadata(req, res xshare.Metadata, servicePath, serviceMethod string, args, reply any) (err error)

func (*XClient) Client

func (xc *XClient) Client(servicePath string) client.XClient

func (*XClient) Close

func (xc *XClient) Close() (err error)

func (*XClient) Has

func (xc *XClient) Has(servicePath string) bool

func (*XClient) Reload added in v0.0.5

func (xc *XClient) Reload() (err error)

func (*XClient) Service added in v0.0.3

func (xc *XClient) Service(name string, handler ...interface{}) *registry.Service

Service 注册服务处理 server 端推送消息

func (*XClient) Size

func (xc *XClient) Size() int

func (*XClient) Start

func (xc *XClient) Start() (err error)

func (*XClient) XCall added in v0.0.3

func (xc *XClient) XCall(ctx context.Context, servicePath, serviceMethod string, args any, reply any) error

XCall 使用默认的message发起请求

Jump to

Keyboard shortcuts

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