xrpc

package
v0.0.0-...-46b248e Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CustomCodec

func CustomCodec(codec codec.Codec)

自定义编解码器

func NewServer

func NewServer(namespace, addr string, etcds []string) (*server.Server, error)

获取server实例

Types

type BaseService

type BaseService struct{}

func (*BaseService) ConvertContext

func (svc *BaseService) ConvertContext(ctx context.Context) context.Context

转换context 系统约定:正常rpcx传递的context中带有traceid(必须)和extra(可选)字段

func (*BaseService) RpcCall

func (svc *BaseService) RpcCall() error

跨服务调用

func (*BaseService) ValidateArgs

func (svc *BaseService) ValidateArgs(arg any) error

转换&验证参数

type JsonCodec

type JsonCodec struct{}

func (*JsonCodec) Decode

func (c *JsonCodec) Decode(data []byte, i interface{}) error

解码

func (*JsonCodec) Encode

func (c *JsonCodec) Encode(i interface{}) ([]byte, error)

编码

type RpcConfig

type RpcConfig struct {
	Namespace string   `mapstructure:"namespace"`
	Type      string   `mapstructure:"type"`
	Hosts     []string `mapstructure:"hosts"`
}

type Service

type Service struct {
	Group   string
	Name    string
	Service any
}

Jump to

Keyboard shortcuts

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