xrpc

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const TypeNode = "rpcs"

Variables

This section is empty.

Functions

func DeregisterClient added in v0.3.0

func DeregisterClient(name string)

Deregister 清理配置适配器

func DeregisterServer added in v0.3.0

func DeregisterServer(name string)

Deregister 清理配置适配器

func IsIpPortAddr added in v0.1.46

func IsIpPortAddr(addr string) (ip string, port int, ok bool)

func NewBuilder

func NewBuilder() container.StandardBuilder

func RegisterClient added in v0.3.0

func RegisterClient(resolver ClientResover)

Register 注册配置文件适配器

func RegisterServer added in v0.3.0

func RegisterServer(resolver ServerResover)

Register 注册配置文件适配器

Types

type Body

type Body interface {
	GetStatus() int32
	GetHeader() map[string]string
	GetResult() []byte
}

type Client

type Client interface {
	//Swap 将当前请求参数作为RPC参数并发送RPC请求
	Swap(ctx context.Context, service string, opts ...RequestOption) (res Body, err error)

	//RequestByCtx RPC请求,可通过context撤销请求
	Request(ctx sctx.Context, service string, input interface{}, opts ...RequestOption) (res Body, err error)
}

type ClientResover added in v0.3.0

type ClientResover interface {
	Name() string
	Resolve(name string, setting config.Config) (Client, error)
}

ClientResover 定义配置文件转换方法

type Config added in v0.3.0

type Config struct {
	Addr           string        `json:"addr"`
	Proto          string        `json:"proto"`
	Status         engine.Status `json:"status"`
	MaxRecvMsgSize int           `json:"max_recv_msg_size"`
	MaxSendMsgSize int           `json:"max_send_msg_size"`
}

type Options

type Options struct {
	Header       xtypes.SMap // map[string]string
	WaitForReady bool
}

type RequestOption

type RequestOption func(*Options)

func WithContentType

func WithContentType(contentType string) RequestOption

func WithHeaders

func WithHeaders(header map[string]string) RequestOption

func WithSourceName added in v0.2.6

func WithSourceName(sourceName string) RequestOption

func WithWaitForReady

func WithWaitForReady(waitForReady bool) RequestOption

func WithXRequestID

func WithXRequestID(requestID string) RequestOption

type Server added in v0.3.0

type Server interface {
	GetProto() string
	GetAddr() string
	Serve(ctx context.Context) (err error)
	Stop(ctx context.Context) error
}

func NewServer added in v0.3.0

func NewServer(proto string,
	router *engine.RouterGroup,
	cfg config.Config,
	opts ...engine.Option) (Server, error)

NewServer 根据适配器名称及参数返回配置处理器

type ServerResover added in v0.3.0

type ServerResover interface {
	Name() string
	Resolve(name string,
		router *engine.RouterGroup,
		cfg config.Config,
		opts ...engine.Option) (Server, error)
}

ServerResover 定义配置文件转换方法

type StandardRPC

type StandardRPC interface {
	GetRPC(name string) (c Client)
}

Jump to

Keyboard shortcuts

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