Documentation
¶
Index ¶
- Constants
- Variables
- func GetRequestTimeout() time.Duration
- func NewOutgoingContext(ctx context.Context, meta Meta) context.Context
- func RegisterEncoder(enc Encoder)
- type App
- type AppOption
- type AppOptionFunc
- type Client
- type ClientConfig
- type ClientOption
- type ClientOptions
- type Config
- type Dispatcher
- type Encoder
- type HttpServer
- type Meta
- type Protocol
- type Request
- func (*Request) Descriptor() ([]byte, []int)deprecated
- func (x *Request) GetBody() []byte
- func (x *Request) GetMeta() map[string]string
- func (x *Request) GetMethod() string
- func (x *Request) GetRequestId() int64
- func (*Request) ProtoMessage()
- func (x *Request) ProtoReflect() protoreflect.Message
- func (x *Request) Reset()
- func (x *Request) String() string
- type Response
- func (*Response) Descriptor() ([]byte, []int)deprecated
- func (x *Response) GetBody() []byte
- func (x *Response) GetCode() int32
- func (x *Response) GetCodeStatus() string
- func (x *Response) GetMeta() map[string]string
- func (x *Response) GetRequestId() int64
- func (*Response) ProtoMessage()
- func (x *Response) ProtoReflect() protoreflect.Message
- func (x *Response) Reset()
- func (x *Response) String() string
- type Server
- type ServerConfig
- type ServerOption
- type ServerOptions
- type TcpServer
Constants ¶
View Source
const ( EncodeType = "encode-type" ConsistentHashKey = "consistenthash" )
Variables ¶
View Source
var ( ErrPageNotFound = fmt.Errorf("404 page not found") ErrMethodNotFound = fmt.Errorf("method not found") )
View Source
var ( ErrServerIsRunning = fmt.Errorf("rpc: server is running") ErrServerIsClosed = fmt.Errorf("rpc: server is closed") )
View Source
var ErrConnectNotFound = fmt.Errorf("connect not found")
View Source
var File_requset_proto protoreflect.FileDescriptor
View Source
var File_response_proto protoreflect.FileDescriptor
Functions ¶
func GetRequestTimeout ¶
func RegisterEncoder ¶
func RegisterEncoder(enc Encoder)
Types ¶
type AppOption ¶
type AppOption interface {
// contains filtered or unexported methods
}
func WithRegister ¶
func WithServer ¶
type AppOptionFunc ¶
type AppOptionFunc func(app *App)
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(name string, opts ...ClientOption) *Client
func (*Client) GetAllEndpoints ¶
type ClientConfig ¶
type ClientConfig struct {
RequestTimeout time.Duration `yaml:"request-timeout"`
ReadBufferSize int32 `yaml:"read-buffer-size"`
Thread int `yaml:"thread"`
MaxIdleTime time.Duration `yaml:"max-idle-time"`
EncodeType string `yaml:"encode-type"`
ReTry int `yaml:"retry"`
}
func GetClientConfig ¶
func GetClientConfig() *ClientConfig
type ClientOption ¶
type ClientOption func(opt *ClientOptions)
func WithClientOptionAddr ¶
func WithClientOptionAddr(addr string) ClientOption
func WithClientOptionEncodeType ¶
func WithClientOptionEncodeType(encodeType string) ClientOption
func WithClientOptionMaxConn ¶
func WithClientOptionMaxConn(max int) ClientOption
func WithClientOptionsDiscover ¶
func WithClientOptionsDiscover(discover discovery.Discover) ClientOption
type ClientOptions ¶
type ClientOptions struct {
// contains filtered or unexported fields
}
type Config ¶
type Config struct {
BaseDir string `yaml:"base-dir"`
LogDir string `yaml:"log-dir"`
DiscoverConfig *discovery.DiscoverConfig `yaml:"discover"`
RegisterConfig *register.RegisterConfig `yaml:"register"`
ServerConfigs []*ServerConfig `yaml:"server-config"`
ClientConfig *ClientConfig `yaml:"client-config"`
}
type Dispatcher ¶
type Encoder ¶
type Encoder interface {
Encode(v interface{}) ([]byte, error)
Decode(bs []byte, addr interface{}) error
Name() string
}
func GetEncoder ¶
type HttpServer ¶
func NewHttpServer ¶
func NewHttpServer(name string, handler http.Handler, opts ...ServerOption) *HttpServer
func (*HttpServer) Name ¶
func (srv *HttpServer) Name() string
func (*HttpServer) Start ¶
func (srv *HttpServer) Start() error
func (*HttpServer) String ¶
func (srv *HttpServer) String() string
func (*HttpServer) Target ¶
func (srv *HttpServer) Target() *register.Target
type Request ¶
type Request struct {
RequestId int64 `protobuf:"varint,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
Method string `protobuf:"bytes,2,opt,name=method,proto3" json:"method,omitempty"`
Meta map[string]string `` /* 149-byte string literal not displayed */
Body []byte `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"`
// contains filtered or unexported fields
}
func (*Request) Descriptor
deprecated
func (*Request) GetRequestId ¶
func (*Request) ProtoMessage ¶
func (*Request) ProtoMessage()
func (*Request) ProtoReflect ¶
func (x *Request) ProtoReflect() protoreflect.Message
type Response ¶
type Response struct {
RequestId int64 `protobuf:"varint,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
Meta map[string]string `` /* 149-byte string literal not displayed */
Body []byte `protobuf:"bytes,3,opt,name=body,proto3" json:"body,omitempty"`
Code int32 `protobuf:"varint,4,opt,name=code,proto3" json:"code,omitempty"`
CodeStatus string `protobuf:"bytes,5,opt,name=code_status,json=codeStatus,proto3" json:"code_status,omitempty"`
// contains filtered or unexported fields
}
func (*Response) Descriptor
deprecated
func (*Response) GetCodeStatus ¶
func (*Response) GetRequestId ¶
func (*Response) ProtoMessage ¶
func (*Response) ProtoMessage()
func (*Response) ProtoReflect ¶
func (x *Response) ProtoReflect() protoreflect.Message
type ServerConfig ¶
type ServerConfig struct {
Name string `yaml:"name"`
IP string `yaml:"ip"`
Port string `yaml:"port"`
MaxInvoke int32 `yaml:"max-invoke"`
ReadBufferSize int32 `yaml:"read-buffer-size"`
}
func GetServerConfig ¶
func GetServerConfig(name string) *ServerConfig
type ServerOption ¶
type ServerOption func(opt *ServerOptions)
func WithServerOptionAddr ¶
func WithServerOptionAddr(addr string) ServerOption
func WithServerOptionReadSize ¶
func WithServerOptionReadSize(size int32) ServerOption
type ServerOptions ¶
type ServerOptions struct {
// contains filtered or unexported fields
}
type TcpServer ¶
type TcpServer struct {
// contains filtered or unexported fields
}
func NewRPCServer ¶
func NewRPCServer(name string, impl interface{}, dispatcher Dispatcher, opts ...ServerOption) *TcpServer
Source Files
¶
Click to show internal directories.
Click to hide internal directories.