Documentation ¶
Overview ¶
Go support for Protocol Buffers RPC which compatiable with https://github.com/Baidu-ecom/Jprotobuf-rpc-socket
Copyright 2002-2007 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Go support for Protocol Buffers RPC which compatiable with https://github.com/Baidu-ecom/Jprotobuf-rpc-socket
Copyright 2002-2007 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Go support for Protocol Buffers RPC which compatiable with https://github.com/Baidu-ecom/Jprotobuf-rpc-socket
Copyright 2002-2007 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Go support for Protocol Buffers RPC which compatiable with https://github.com/Baidu-ecom/Jprotobuf-rpc-socket
Copyright 2002-2007 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Go support for Protocol Buffers RPC which compatiable with https://github.com/Baidu-ecom/Jprotobuf-rpc-socket
Copyright 2002-2007 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
- @Author: Malin Xie
- @Description:
- @Date: 2021-04-26 18:18:59
Go support for Protocol Buffers RPC which compatiable with https://github.com/Baidu-ecom/Jprotobuf-rpc-socket
Copyright 2002-2007 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Go support for Protocol Buffers RPC which compatiable with https://github.com/Baidu-ecom/Jprotobuf-rpc-socket
Copyright 2002-2007 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
- @Author: Malin Xie
- @Description:
- @Date: 2021-08-19 13:22:01
Go support for Protocol Buffers RPC which compatiable with https://github.com/Baidu-ecom/Jprotobuf-rpc-socket
Copyright 2002-2007 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Go support for Protocol Buffers RPC which compatiable with https://github.com/Baidu-ecom/Jprotobuf-rpc-socket
Copyright 2002-2007 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Go support for Protocol Buffers RPC which compatiable with https://github.com/Baidu-ecom/Jprotobuf-rpc-socket
Copyright 2002-2007 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Go support for Protocol Buffers RPC which compatiable with https://github.com/Baidu-ecom/Jprotobuf-rpc-socket
Copyright 2002-2007 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
- @Author: Malin Xie
- @Description:
- @Date: 2021-07-26 17:09:25
Go support for Protocol Buffers RPC which compatiable with https://github.com/Baidu-ecom/Jprotobuf-rpc-socket
Copyright 2002-2007 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func Attachement(context context.Context) []byte
- func BindAttachement(c context.Context, attachement interface{}) context.Context
- func BindError(c context.Context, err error) context.Context
- func BindLogId(c context.Context, logid int64) context.Context
- func CloseBatchConnection(connections []Connection)
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Errors(c context.Context) error
- func GUNZIP(b []byte) ([]byte, error)
- func GZIP(b []byte) ([]byte, error)
- func GetServiceId(serviceName, methodName string) string
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func LogID(context context.Context) int64
- func TimetookInSeconds(currentNano int64) float64
- func UnescapeUnicode(raw []byte) ([]byte, error)
- func Warning(args ...interface{})
- func Warningf(format string, args ...interface{})
- type AuthService
- type ChunkInfo
- type Connection
- type ConnectionPoolFactory
- func (c *ConnectionPoolFactory) ActivateObject(ctx context.Context, object *pool.PooledObject) error
- func (c *ConnectionPoolFactory) DestroyObject(ctx context.Context, object *pool.PooledObject) error
- func (c *ConnectionPoolFactory) MakeObject(ctx context.Context) (*pool.PooledObject, error)
- func (c *ConnectionPoolFactory) PassivateObject(ctx context.Context, object *pool.PooledObject) error
- func (c *ConnectionPoolFactory) ValidateObject(ctx context.Context, object *pool.PooledObject) bool
- type ConnectionTester
- type DefaultService
- type ErrorContext
- type HaRpcClient
- type Header
- func (h *Header) GetMagicCode() []byte
- func (h *Header) GetMessageSize() int32
- func (h *Header) GetMetaSize() int32
- func (h *Header) Read(bytes []byte) error
- func (h *Header) SetMagicCode(MagicCode []byte)
- func (h *Header) SetMessageSize(MessageSize int32)
- func (h *Header) SetMetaSize(MetaSize int32)
- func (h *Header) Write() ([]byte, error)
- type HttpServer
- type HttpStatusView
- type PbFieldMeta
- type QpsData
- type RPCFN
- type RPCMethod
- func (*RPCMethod) Descriptor() ([]byte, []int)deprecated
- func (x *RPCMethod) GetInTypeMeta() string
- func (x *RPCMethod) GetMethod() string
- func (x *RPCMethod) GetReturnTypeMeta() string
- func (x *RPCMethod) GetService() string
- func (*RPCMethod) ProtoMessage()
- func (x *RPCMethod) ProtoReflect() protoreflect.Message
- func (x *RPCMethod) Reset()
- func (x *RPCMethod) String() string
- type RPCMethodReuqestStatus
- type RPCRequestStatus
- type RPCStatus
- func (*RPCStatus) Descriptor() ([]byte, []int)deprecated
- func (x *RPCStatus) GetHost() string
- func (x *RPCStatus) GetMethods() []*RPCMethod
- func (x *RPCStatus) GetPort() int32
- func (x *RPCStatus) GetTimeout() int32
- func (*RPCStatus) ProtoMessage()
- func (x *RPCStatus) ProtoReflect() protoreflect.Message
- func (x *RPCStatus) Reset()
- func (x *RPCStatus) String() string
- type Readable
- type Request
- func (*Request) Descriptor() ([]byte, []int)deprecated
- func (x *Request) GetExtraParam() []byte
- func (x *Request) GetLogId() int64
- func (x *Request) GetMethodName() string
- func (x *Request) GetParentSpanId() int64
- func (x *Request) GetRpcRequestMetaExt() []*RpcRequestMetaExtField
- func (x *Request) GetServiceName() string
- func (x *Request) GetSpanId() int64
- func (x *Request) GetTraceId() int64
- func (*Request) ProtoMessage()
- func (x *Request) ProtoReflect() protoreflect.Message
- func (x *Request) Reset()
- func (x *Request) String() string
- type Response
- type ResponseData
- type RpcClient
- func (c *RpcClient) Close()
- func (c *RpcClient) SendRpcRequest(rpcInvocation *RpcInvocation, responseMessage proto.Message) (*RpcDataPackage, error)
- func (c *RpcClient) SendRpcRequestAsyc(rpcInvocation *RpcInvocation, responseMessage proto.Message) <-chan *RpcResult
- func (c *RpcClient) SendRpcRequestWithTimeout(timeout time.Duration, rpcInvocation *RpcInvocation, ...) (*RpcDataPackage, error)
- type RpcDataPackage
- func (r *RpcDataPackage) AuthenticationData(authenticationData []byte) *RpcDataPackage
- func (r *RpcDataPackage) ChuckInfo(streamId int64, chunkId int64) *RpcDataPackage
- func (r *RpcDataPackage) Chunk(chunkSize int) []*RpcDataPackage
- func (r *RpcDataPackage) ClearChunkStatus()
- func (r *RpcDataPackage) CompressType(compressType int32) *RpcDataPackage
- func (r *RpcDataPackage) CorrelationId(correlationId int64) *RpcDataPackage
- func (r *RpcDataPackage) ErrorCode(errorCode int32) *RpcDataPackage
- func (r *RpcDataPackage) ErrorText(errorText string) *RpcDataPackage
- func (r *RpcDataPackage) ExtraParams(extraParams []byte) *RpcDataPackage
- func (r *RpcDataPackage) GetAttachment() []byte
- func (r *RpcDataPackage) GetChunkStreamId() int64
- func (r *RpcDataPackage) GetData() []byte
- func (r *RpcDataPackage) GetHead() *Header
- func (r *RpcDataPackage) GetLogId() int64
- func (r *RpcDataPackage) GetMagicCode() string
- func (r *RpcDataPackage) GetMeta() *RpcMeta
- func (r *RpcDataPackage) GetParentSpanId() int64
- func (r *RpcDataPackage) GetRpcRequestMetaExt() map[string]string
- func (r *RpcDataPackage) GetSpanId() int64
- func (r *RpcDataPackage) GetTraceId() int64
- func (r *RpcDataPackage) IsChunkPackage() bool
- func (r *RpcDataPackage) IsFinalPackage() bool
- func (r *RpcDataPackage) LogId(logId int64) *RpcDataPackage
- func (r *RpcDataPackage) MagicCode(magicCode string)
- func (r *RpcDataPackage) MethodName(methodName string) *RpcDataPackage
- func (r *RpcDataPackage) ParentSpanId(parentSpanId int64) *RpcDataPackage
- func (r *RpcDataPackage) Read(b []byte) error
- func (r *RpcDataPackage) ReadIO(rw io.Reader) error
- func (r *RpcDataPackage) RpcRequestMetaExt(ext map[string]string) *RpcDataPackage
- func (r *RpcDataPackage) ServiceName(serviceName string) *RpcDataPackage
- func (r *RpcDataPackage) SetAttachment(Attachment []byte) *RpcDataPackage
- func (r *RpcDataPackage) SetData(Data []byte) *RpcDataPackage
- func (r *RpcDataPackage) SpanId(spanId int64) *RpcDataPackage
- func (r *RpcDataPackage) TraceId(traceId int64) *RpcDataPackage
- func (r *RpcDataPackage) Write() ([]byte, error)
- func (r *RpcDataPackage) WriteIO(rw io.Writer) error
- type RpcDataPackageCodec
- type RpcDataPackageProtocol
- type RpcInvocation
- type RpcMeta
- func (*RpcMeta) Descriptor() ([]byte, []int)deprecated
- func (x *RpcMeta) GetAttachmentSize() int32
- func (x *RpcMeta) GetAuthenticationData() []byte
- func (x *RpcMeta) GetChuckInfo() *ChunkInfo
- func (x *RpcMeta) GetCompressType() int32
- func (x *RpcMeta) GetCorrelationId() int64
- func (x *RpcMeta) GetRequest() *Request
- func (x *RpcMeta) GetResponse() *Response
- func (*RpcMeta) ProtoMessage()
- func (x *RpcMeta) ProtoReflect() protoreflect.Message
- func (x *RpcMeta) Reset()
- func (x *RpcMeta) String() string
- type RpcRequestMetaExtField
- func (*RpcRequestMetaExtField) Descriptor() ([]byte, []int)deprecated
- func (x *RpcRequestMetaExtField) GetKey() string
- func (x *RpcRequestMetaExtField) GetValue() string
- func (*RpcRequestMetaExtField) ProtoMessage()
- func (x *RpcRequestMetaExtField) ProtoReflect() protoreflect.Message
- func (x *RpcRequestMetaExtField) Reset()
- func (x *RpcRequestMetaExtField) String() string
- type RpcResult
- type Server
- type ServerMeta
- type Service
- type TCPConnection
- func (c *TCPConnection) Close() error
- func (c *TCPConnection) GetId() uint64
- func (c *TCPConnection) Receive() (*RpcDataPackage, error)
- func (c *TCPConnection) Reconnect() error
- func (c *TCPConnection) Send(rpcDataPackage *RpcDataPackage) error
- func (c *TCPConnection) SendReceive(rpcDataPackage *RpcDataPackage) (*RpcDataPackage, error)
- func (c *TCPConnection) TestConnection() error
- type TCPConnectionPool
- func (c *TCPConnectionPool) Close() error
- func (c *TCPConnectionPool) GetNumActive() int
- func (c *TCPConnectionPool) Receive() (*RpcDataPackage, error)
- func (c *TCPConnectionPool) Reconnect() error
- func (c *TCPConnectionPool) Send(rpcDataPackage *RpcDataPackage) error
- func (c *TCPConnectionPool) SendReceive(rpcDataPackage *RpcDataPackage) (*RpcDataPackage, error)
- type TcpServer
- func (s *TcpServer) EnableHttp()
- func (s *TcpServer) Register(service interface{}) (bool, error)
- func (s *TcpServer) RegisterName(name string, rcvr interface{}) (bool, error)
- func (s *TcpServer) RegisterNameWithMethodMapping(name string, rcvr interface{}, mapping map[string]string) (bool, error)
- func (s *TcpServer) RegisterRpc(sname, mname string, callback RPCFN, inType proto.Message) (bool, error)
- func (s *TcpServer) SetAuthService(authservice AuthService)
- func (s *TcpServer) SetTraceService(traceService TraceService)
- func (s *TcpServer) Start() error
- func (s *TcpServer) StartAndBlock() error
- func (s *TcpServer) StartServer(l net.Listener) error
- func (s *TcpServer) Stop(ctx context.Context) error
- type TraceInfo
- type TraceService
- type URL
- type Writable
Constants ¶
const ( SIZE = 12 MagicSize = 4 MAGIC_CODE = "PRPC" COMPRESS_NO int32 = 0 COMPRESS_SNAPPY int32 = 1 COMPRESS_GZIP int32 = 2 )
const ( HttpRpcPath = "/rpc/" LogId_key = "X-LogID" Auth_key = "X-Authenticate" Trace_Id_key = "X-Trace_ID" Trace_Span_key = "X-Trace_Span" Trace_Parent_key = "X-Trace_Parent" Request_Meta_Key = "X-Request-Meta" // Json value )
const ( /** success status. */ ST_SUCCESS int = 0 /** 方法未找到异常. */ ST_SERVICE_NOTFOUND int = 1001 /** 未知异常. */ ST_ERROR int = 2001 /** 验证错误. */ ST_AUTH_ERROR = 1004 // log id key KT_LOGID = "_logid_" RPC_STATUS_SERVICENAME = "___baidurpc_service" // in seconds Reqeust_QPS_Expire = 300 // Proto2_Version = "proto2" Shutdown_Timeout = time.Second )
const REQUIRED_TYPE = "baidurpc.RpcDataPackage"
const (
ST_READ_TIMEOUT = 62
)
Variables ¶
var ( LOG_SERVER_REPONSE_ERROR = "[client-002]Server response error. code=%d, msg='%s'" LOG_CLIENT_TIMECOUST_INFO = "[client-101]Server name '%s' method '%s' process cost '%.5g' seconds" )
var ( Empty_Head = make([]byte, SIZE) HB_SERVICE_NAME = "__heartbeat" HB_METHOD_NAME = "__beat" )
var ( LOG_SERVICE_NOTFOUND = "[server-" + strconv.Itoa(ST_SERVICE_NOTFOUND) + "]Service name '%s' or method name '%s' not found" LOG_SERVICE_DUPLICATE = "[server-004]Service name '%s' or method name '%s' already exist" LOG_SERVER_STARTED_INFO = "[server-100]BaiduRpc server started on '%v'" LOG_INTERNAL_ERROR = "[server-" + strconv.Itoa(ST_ERROR) + "] unknown internal error:'%s'" LOG_TIMECOST_INFO = "[server-101]Server name '%s' method '%s' process cost '%.5g' seconds" LOG_TIMECOST_INFO2 = "[server-102]Server name '%s' method '%s' process cost '%.5g' seconds.(without net cost) " DEAFULT_IDLE_TIME_OUT_SECONDS = 10 MessageType = reflect.TypeOf(m) )
error log info definition
var File_brpc_meta_proto protoreflect.FileDescriptor
var File_go_proto protoreflect.FileDescriptor
var (
LOG_CLOSE_CONNECT_INFO = "[codec-100]Do close connection. connection info:%v"
)
var (
LOG_INVALID_BYTES = "[marshal-004]Invalid byte array. maybe a broken byte stream. Received '%b'"
)
error log info definition
var (
LOG_INVALID_PORT = "[conn-003]invalid parameter 'url' of port property is '%d'"
)
var NANO_IN_SECONDS = 1000000000.0
Functions ¶
func Attachement ¶
Attachment utility function to get attachemnt from context
func BindAttachement ¶
BindAttachement add attachement value to the context
func CloseBatchConnection ¶
func CloseBatchConnection(connections []Connection)
CloseBatchConnection close batch connections
func Error ¶
func Error(args ...interface{})
Error logs to the ERROR, WARNING, and INFO logs. Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf logs to the ERROR, WARNING, and INFO logs. Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
func GetServiceId ¶
func Info ¶
func Info(args ...interface{})
Info logs to the INFO log. Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
func Infof ¶
func Infof(format string, args ...interface{})
Infof logs to the INFO log. Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
func UnescapeUnicode ¶ added in v1.1.3
UnescapeUnicode
Types ¶
type AuthService ¶ added in v1.1.1
type AuthService interface { // Authenticate do auth action if return true auth success Authenticate(service, name string, authToken []byte) bool }
AuthService authenticate service
type ChunkInfo ¶
type ChunkInfo struct { StreamId int64 `protobuf:"varint,1,opt,name=stream_id,json=streamId,proto3" json:"stream_id,omitempty"` ChunkId int64 `protobuf:"varint,2,opt,name=chunk_id,json=chunkId,proto3" json:"chunk_id,omitempty"` // contains filtered or unexported fields }
func (*ChunkInfo) Descriptor
deprecated
func (*ChunkInfo) GetChunkId ¶
func (*ChunkInfo) GetStreamId ¶
func (*ChunkInfo) ProtoMessage ¶
func (*ChunkInfo) ProtoMessage()
func (*ChunkInfo) ProtoReflect ¶ added in v1.3.0
func (x *ChunkInfo) ProtoReflect() protoreflect.Message
type Connection ¶
type Connection interface { SendReceive(rpcDataPackage *RpcDataPackage) (*RpcDataPackage, error) Send(rpcDataPackage *RpcDataPackage) error Receive() (*RpcDataPackage, error) Close() error Reconnect() error }
Connection handler interface
func NewBatchTCPConnection ¶
func NewBatchTCPConnection(urls []URL, timeout time.Duration) ([]Connection, error)
NewBatchTCPConnection to create batch connection
type ConnectionPoolFactory ¶
type ConnectionPoolFactory struct {
// contains filtered or unexported fields
}
func (*ConnectionPoolFactory) ActivateObject ¶
func (c *ConnectionPoolFactory) ActivateObject(ctx context.Context, object *pool.PooledObject) error
func (*ConnectionPoolFactory) DestroyObject ¶
func (c *ConnectionPoolFactory) DestroyObject(ctx context.Context, object *pool.PooledObject) error
func (*ConnectionPoolFactory) MakeObject ¶
func (c *ConnectionPoolFactory) MakeObject(ctx context.Context) (*pool.PooledObject, error)
func (*ConnectionPoolFactory) PassivateObject ¶
func (c *ConnectionPoolFactory) PassivateObject(ctx context.Context, object *pool.PooledObject) error
func (*ConnectionPoolFactory) ValidateObject ¶
func (c *ConnectionPoolFactory) ValidateObject(ctx context.Context, object *pool.PooledObject) bool
type ConnectionTester ¶
type ConnectionTester interface {
TestConnection() error
}
type DefaultService ¶
type DefaultService struct {
// contains filtered or unexported fields
}
DefaultService default implemention for Service interface
func (*DefaultService) DoService ¶
func (s *DefaultService) DoService(message proto.Message, attachment []byte, logId *int64) (proto.Message, []byte, error)
DoService do call back function on RPC invocation
func (*DefaultService) GetMethodName ¶
func (s *DefaultService) GetMethodName() string
GetMethodName get method name
func (*DefaultService) GetServiceName ¶
func (s *DefaultService) GetServiceName() string
GetServiceName get service name
func (*DefaultService) NewParameter ¶
func (s *DefaultService) NewParameter() proto.Message
NewParameter no long will be used
type ErrorContext ¶ added in v1.0.6
type ErrorContext struct {
// contains filtered or unexported fields
}
ErrorContext
type HaRpcClient ¶
type HaRpcClient struct {
// contains filtered or unexported fields
}
HaRpcClient high avialbe RpcClient
func NewHaRpcCient ¶
func NewHaRpcCient(connections []Connection) (*HaRpcClient, error)
NewHaRpcCient
func NewHaRpcCientWithTimewheelSetting ¶ added in v1.1.1
func NewHaRpcCientWithTimewheelSetting(connections []Connection, timewheelInterval time.Duration, timewheelSlot uint16) (*HaRpcClient, error)
NewHaRpcCient
func (*HaRpcClient) SendRpcRequest ¶
func (c *HaRpcClient) SendRpcRequest(rpcInvocation *RpcInvocation, responseMessage proto.Message) (*RpcDataPackage, error)
SendRpcRequest send rpc request by elect one client
func (*HaRpcClient) SendRpcRequestWithTimeout ¶ added in v1.1.1
func (c *HaRpcClient) SendRpcRequestWithTimeout(timeout time.Duration, rpcInvocation *RpcInvocation, responseMessage proto.Message) (*RpcDataPackage, error)
SendRpcRequest send rpc request by elect one client with timeout feature
type Header ¶
RPC header content
func (*Header) GetMagicCode ¶
func (*Header) GetMessageSize ¶
func (*Header) GetMetaSize ¶
func (*Header) SetMagicCode ¶
func (*Header) SetMessageSize ¶
func (*Header) SetMetaSize ¶
type HttpServer ¶ added in v1.1.3
type HttpServer struct {
// contains filtered or unexported fields
}
func (*HttpServer) ServeHTTP ¶ added in v1.1.3
func (h *HttpServer) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP to serve http reqeust and response to process http rpc handle
type HttpStatusView ¶ added in v1.0.11
type HttpStatusView struct {
// contains filtered or unexported fields
}
HttpStatusView
func (*HttpStatusView) QpsDataStatus ¶ added in v1.0.11
type PbFieldMeta ¶ added in v1.0.12
type PbFieldMeta struct { Name string `json:"name,omitempty"` Tag int `json:"tag,omitempty"` Type string `json:"type,omitempty"` Opt string `json:"opt,omitempty"` // opt or req Version string `json:"version,omitempty"` // proto2 or proto3 SubFieldMeta []*PbFieldMeta `json:"sub_field_meta,omitempty"` HasSub bool `json:"has_sub,omitempty"` }
type QpsData ¶ added in v1.0.11
type QpsData struct { Qpsinfo map[int64]int32 `` /* 157-byte string literal not displayed */ // contains filtered or unexported fields }
func (*QpsData) Descriptor
deprecated
added in
v1.3.0
func (*QpsData) GetQpsinfo ¶ added in v1.3.0
func (*QpsData) ProtoMessage ¶ added in v1.0.11
func (*QpsData) ProtoMessage()
func (*QpsData) ProtoReflect ¶ added in v1.3.0
func (x *QpsData) ProtoReflect() protoreflect.Message
type RPCMethod ¶ added in v1.0.11
type RPCMethod struct { Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` Method string `protobuf:"bytes,2,opt,name=method,proto3" json:"method,omitempty"` InTypeMeta string `protobuf:"bytes,3,opt,name=intype,proto3" json:"intype,omitempty"` ReturnTypeMeta string `protobuf:"bytes,4,opt,name=returntype,proto3" json:"returntype,omitempty"` // contains filtered or unexported fields }
func (*RPCMethod) Descriptor
deprecated
added in
v1.3.0
func (*RPCMethod) GetInTypeMeta ¶ added in v1.3.0
func (*RPCMethod) GetReturnTypeMeta ¶ added in v1.3.0
func (*RPCMethod) GetService ¶ added in v1.3.0
func (*RPCMethod) ProtoMessage ¶ added in v1.0.11
func (*RPCMethod) ProtoMessage()
func (*RPCMethod) ProtoReflect ¶ added in v1.3.0
func (x *RPCMethod) ProtoReflect() protoreflect.Message
type RPCMethodReuqestStatus ¶ added in v1.0.11
RPCMethodReuqestStatus
type RPCRequestStatus ¶ added in v1.0.11
type RPCRequestStatus struct { Methods map[string]*RPCMethodReuqestStatus // contains filtered or unexported fields }
RPCRequestStatus
func NewRPCRequestStatus ¶ added in v1.0.11
func NewRPCRequestStatus(services map[string]Service) *RPCRequestStatus
NewRPCRequestStatus
type RPCStatus ¶ added in v1.0.11
type RPCStatus struct { Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` Port int32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"` TimeoutSenconds int32 `protobuf:"varint,3,opt,name=timeout,proto3" json:"timeout,omitempty"` Methods []*RPCMethod `protobuf:"bytes,4,rep,name=methods,proto3" json:"methods,omitempty"` // contains filtered or unexported fields }
func (*RPCStatus) Descriptor
deprecated
added in
v1.3.0
func (*RPCStatus) GetMethods ¶ added in v1.3.0
func (*RPCStatus) GetTimeout ¶ added in v1.3.0
func (*RPCStatus) ProtoMessage ¶ added in v1.0.11
func (*RPCStatus) ProtoMessage()
func (*RPCStatus) ProtoReflect ¶ added in v1.3.0
func (x *RPCStatus) ProtoReflect() protoreflect.Message
type Readable ¶
Readable is the interface that deserialize from []byte if errror ocurres should return non-nil error
type Request ¶
type Request struct { ServiceName string `protobuf:"bytes,1,opt,name=service_name,json=serviceName,proto3" json:"service_name,omitempty"` MethodName string `protobuf:"bytes,2,opt,name=method_name,json=methodName,proto3" json:"method_name,omitempty"` LogId int64 `protobuf:"varint,3,opt,name=log_id,json=logId,proto3" json:"log_id,omitempty"` TraceId int64 `protobuf:"varint,4,opt,name=traceId,proto3" json:"traceId,omitempty"` SpanId int64 `protobuf:"varint,5,opt,name=spanId,proto3" json:"spanId,omitempty"` ParentSpanId int64 `protobuf:"varint,6,opt,name=parentSpanId,proto3" json:"parentSpanId,omitempty"` RpcRequestMetaExt []*RpcRequestMetaExtField `protobuf:"bytes,7,rep,name=rpcRequestMetaExt,proto3" json:"rpcRequestMetaExt,omitempty"` ExtraParam []byte `protobuf:"bytes,110,opt,name=extraParam,proto3" json:"extraParam,omitempty"` // contains filtered or unexported fields }
func (*Request) Descriptor
deprecated
func (*Request) GetExtraParam ¶
func (*Request) GetMethodName ¶
func (*Request) GetParentSpanId ¶ added in v1.3.0
func (*Request) GetRpcRequestMetaExt ¶ added in v1.3.0
func (x *Request) GetRpcRequestMetaExt() []*RpcRequestMetaExtField
func (*Request) GetServiceName ¶
func (*Request) GetTraceId ¶ added in v1.3.0
func (*Request) ProtoMessage ¶
func (*Request) ProtoMessage()
func (*Request) ProtoReflect ¶ added in v1.3.0
func (x *Request) ProtoReflect() protoreflect.Message
type Response ¶
type Response struct { ErrorCode int32 `protobuf:"varint,1,opt,name=error_code,json=errorCode,proto3" json:"error_code,omitempty"` ErrorText string `protobuf:"bytes,2,opt,name=error_text,json=errorText,proto3" json:"error_text,omitempty"` // contains filtered or unexported fields }
func (*Response) Descriptor
deprecated
func (*Response) GetErrorCode ¶
func (*Response) GetErrorText ¶
func (*Response) ProtoMessage ¶
func (*Response) ProtoMessage()
func (*Response) ProtoReflect ¶ added in v1.3.0
func (x *Response) ProtoReflect() protoreflect.Message
type ResponseData ¶ added in v1.1.3
type ResponseData struct { ErrNo int `json:"errno"` Message string `json:"message,omitempty"` Data interface{} `json:"data,omitempty"` }
ResponseData
type RpcClient ¶
type RpcClient struct { Session Connection // contains filtered or unexported fields }
RPC client invoke
func NewRpcCient ¶
func NewRpcCient(connection Connection) (*RpcClient, error)
NewRpcCient new rpc client
func NewRpcCientWithTimeWheelSetting ¶ added in v1.1.1
func NewRpcCientWithTimeWheelSetting(connection Connection, timewheelInterval time.Duration, timewheelSlot uint16) (*RpcClient, error)
NewRpcCientWithTimeWheelSetting new rpc client with set timewheel settings
func (*RpcClient) Close ¶ added in v1.1.1
func (c *RpcClient) Close()
define client methods Close close client with time wheel
func (*RpcClient) SendRpcRequest ¶
func (c *RpcClient) SendRpcRequest(rpcInvocation *RpcInvocation, responseMessage proto.Message) (*RpcDataPackage, error)
SendRpcRequest send rpc request to remote server
func (*RpcClient) SendRpcRequestAsyc ¶ added in v1.1.1
func (c *RpcClient) SendRpcRequestAsyc(rpcInvocation *RpcInvocation, responseMessage proto.Message) <-chan *RpcResult
SendRpcRequestAsyc send rpc request to remote server in asynchronous way
func (*RpcClient) SendRpcRequestWithTimeout ¶ added in v1.1.1
func (c *RpcClient) SendRpcRequestWithTimeout(timeout time.Duration, rpcInvocation *RpcInvocation, responseMessage proto.Message) (*RpcDataPackage, error)
SendRpcRequest send rpc request to remote server
type RpcDataPackage ¶
type RpcDataPackage struct { Head *Header // rpc head Meta *RpcMeta // rpc meta Data []byte Attachment []byte // contains filtered or unexported fields }
Data package for baidu RPC. all request and response data package should apply this.
----------------------------------- | Head | Meta | Data | Attachment | -----------------------------------
1. <Head> with fixed 12 byte length as follow format ---------------------------------------------- | PRPC | MessageSize(int32) | MetaSize(int32) | ---------------------------------------------- MessageSize = totalSize - 12(Fixed Head Size) MetaSize = Meta object size
2. <Meta> body proto description as follow
message RpcMeta { optional Request request = 1; optional Response response = 2; optional int32 compress_type = 3; // 0:nocompress 1:Snappy 2:gzip optional int64 correlation_id = 4; optional int32 attachment_size = 5; optional ChuckInfo chuck_info = 6; optional bytes authentication_data = 7; };
message Request { required string service_name = 1; required string method_name = 2; optional int64 log_id = 3; optional int64 traceId=4; optional int64 spanId=5; optional int64 parentSpanId=6; repeat RpcRequestMetaExtField extFields = 7; };
message RpcRequestMetaExtField { optional string key = 1; optional string value = 2; }
message Response { optional int32 error_code = 1; optional string error_text = 2; };
messsage ChuckInfo { required int64 stream_id = 1; required int64 chunk_id = 2; };
3. <Data> customize transport data message.
4. <Attachment> attachment body data message
func NewRpcDataPackage ¶
func NewRpcDataPackage() *RpcDataPackage
func (*RpcDataPackage) AuthenticationData ¶
func (r *RpcDataPackage) AuthenticationData(authenticationData []byte) *RpcDataPackage
func (*RpcDataPackage) ChuckInfo ¶ added in v1.3.0
func (r *RpcDataPackage) ChuckInfo(streamId int64, chunkId int64) *RpcDataPackage
func (*RpcDataPackage) Chunk ¶ added in v1.1.1
func (r *RpcDataPackage) Chunk(chunkSize int) []*RpcDataPackage
Chunk chunk to small packages by chunk size
func (*RpcDataPackage) ClearChunkStatus ¶ added in v1.1.1
func (r *RpcDataPackage) ClearChunkStatus()
func (*RpcDataPackage) CompressType ¶
func (r *RpcDataPackage) CompressType(compressType int32) *RpcDataPackage
func (*RpcDataPackage) CorrelationId ¶
func (r *RpcDataPackage) CorrelationId(correlationId int64) *RpcDataPackage
func (*RpcDataPackage) ErrorCode ¶
func (r *RpcDataPackage) ErrorCode(errorCode int32) *RpcDataPackage
func (*RpcDataPackage) ErrorText ¶
func (r *RpcDataPackage) ErrorText(errorText string) *RpcDataPackage
func (*RpcDataPackage) ExtraParams ¶
func (r *RpcDataPackage) ExtraParams(extraParams []byte) *RpcDataPackage
func (*RpcDataPackage) GetAttachment ¶
func (r *RpcDataPackage) GetAttachment() []byte
func (*RpcDataPackage) GetChunkStreamId ¶ added in v1.1.1
func (r *RpcDataPackage) GetChunkStreamId() int64
GetChunkStreamId
func (*RpcDataPackage) GetData ¶
func (r *RpcDataPackage) GetData() []byte
func (*RpcDataPackage) GetHead ¶
func (r *RpcDataPackage) GetHead() *Header
func (*RpcDataPackage) GetLogId ¶
func (r *RpcDataPackage) GetLogId() int64
func (*RpcDataPackage) GetMagicCode ¶
func (r *RpcDataPackage) GetMagicCode() string
func (*RpcDataPackage) GetMeta ¶
func (r *RpcDataPackage) GetMeta() *RpcMeta
func (*RpcDataPackage) GetParentSpanId ¶ added in v1.1.1
func (r *RpcDataPackage) GetParentSpanId() int64
func (*RpcDataPackage) GetRpcRequestMetaExt ¶ added in v1.1.1
func (r *RpcDataPackage) GetRpcRequestMetaExt() map[string]string
func (*RpcDataPackage) GetSpanId ¶ added in v1.1.1
func (r *RpcDataPackage) GetSpanId() int64
func (*RpcDataPackage) GetTraceId ¶ added in v1.1.1
func (r *RpcDataPackage) GetTraceId() int64
func (*RpcDataPackage) IsChunkPackage ¶ added in v1.1.1
func (r *RpcDataPackage) IsChunkPackage() bool
IsChunkPackage
func (*RpcDataPackage) IsFinalPackage ¶ added in v1.1.1
func (r *RpcDataPackage) IsFinalPackage() bool
IsFinalPackage
func (*RpcDataPackage) LogId ¶
func (r *RpcDataPackage) LogId(logId int64) *RpcDataPackage
func (*RpcDataPackage) MagicCode ¶
func (r *RpcDataPackage) MagicCode(magicCode string)
func (*RpcDataPackage) MethodName ¶
func (r *RpcDataPackage) MethodName(methodName string) *RpcDataPackage
func (*RpcDataPackage) ParentSpanId ¶ added in v1.1.1
func (r *RpcDataPackage) ParentSpanId(parentSpanId int64) *RpcDataPackage
func (*RpcDataPackage) Read ¶
func (r *RpcDataPackage) Read(b []byte) error
func (*RpcDataPackage) ReadIO ¶
func (r *RpcDataPackage) ReadIO(rw io.Reader) error
Read byte array and initialize RpcPackage
func (*RpcDataPackage) RpcRequestMetaExt ¶ added in v1.1.1
func (r *RpcDataPackage) RpcRequestMetaExt(ext map[string]string) *RpcDataPackage
func (*RpcDataPackage) ServiceName ¶
func (r *RpcDataPackage) ServiceName(serviceName string) *RpcDataPackage
func (*RpcDataPackage) SetAttachment ¶
func (r *RpcDataPackage) SetAttachment(Attachment []byte) *RpcDataPackage
func (*RpcDataPackage) SetData ¶
func (r *RpcDataPackage) SetData(Data []byte) *RpcDataPackage
func (*RpcDataPackage) SpanId ¶ added in v1.1.1
func (r *RpcDataPackage) SpanId(spanId int64) *RpcDataPackage
func (*RpcDataPackage) TraceId ¶ added in v1.1.1
func (r *RpcDataPackage) TraceId(traceId int64) *RpcDataPackage
func (*RpcDataPackage) Write ¶
func (r *RpcDataPackage) Write() ([]byte, error)
Convert RpcPackage to byte array
type RpcDataPackageCodec ¶
type RpcDataPackageCodec[S, R *RpcDataPackage] struct { // contains filtered or unexported fields }
Codec implements for RpcDataPackage.
func (*RpcDataPackageCodec[S, R]) Close ¶
func (r *RpcDataPackageCodec[S, R]) Close() error
do close connection io return non-nil if any error ocurred while doing close
func (*RpcDataPackageCodec[S, R]) Receive ¶
func (r *RpcDataPackageCodec[S, R]) Receive() (*RpcDataPackage, error)
receive serialized data to target server by connection IO return param: 1. RpcDataPackage unserialized from connection io. or nil if exception found 2. a non-nil error if any io exception occured
func (*RpcDataPackageCodec[S, R]) Send ¶
func (r *RpcDataPackageCodec[S, R]) Send(msg *RpcDataPackage) error
send serialized data to target server by connection IO msg: param 'msg' must type of RpcDataPackage
func (*RpcDataPackageCodec[S, R]) SetTimeout ¶
func (r *RpcDataPackageCodec[S, R]) SetTimeout(timeout *time.Duration)
set connection io read and write dead line
type RpcDataPackageProtocol ¶
type RpcDataPackageProtocol[S, R *RpcDataPackage] struct { // contains filtered or unexported fields }
Protocol codec factory object for RpcDataPackage
func NewRpcDataPackageProtocol ¶ added in v1.1.1
func NewRpcDataPackageProtocol[S, R *RpcDataPackage]() (*RpcDataPackageProtocol[S, R], error)
NewRpcDataPackageProtocol create a RpcDataPackageProtocol and start timewheel
func (*RpcDataPackageProtocol[S, R]) NewCodec ¶
func (r *RpcDataPackageProtocol[S, R]) NewCodec(rw io.ReadWriter) (link.Codec[*RpcDataPackage, *RpcDataPackage], error)
func (*RpcDataPackageProtocol[S, R]) Stop ¶ added in v1.1.1
func (r *RpcDataPackageProtocol[S, R]) Stop()
Stop
type RpcInvocation ¶
type RpcInvocation struct { ServiceName *string MethodName *string ParameterIn *proto.Message Attachment []byte LogId *int64 CompressType *int32 AuthenticateData []byte ChunkSize uint32 TraceId int64 SpanId int64 ParentSpanId int64 RpcRequestMetaExt map[string]string }
RpcInvocation define rpc invocation
func NewRpcInvocation ¶
func NewRpcInvocation(serviceName, methodName *string) *RpcInvocation
NewRpcInvocation create RpcInvocation with service name and method name
func (*RpcInvocation) GetRequestRpcDataPackage ¶
func (r *RpcInvocation) GetRequestRpcDataPackage() (*RpcDataPackage, error)
GetRequestRpcDataPackage
func (*RpcInvocation) SetParameterIn ¶
func (r *RpcInvocation) SetParameterIn(parameterIn proto.Message)
SetParameterIn
type RpcMeta ¶
type RpcMeta struct { Request *Request `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"` Response *Response `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"` CompressType int32 `protobuf:"varint,3,opt,name=compress_type,json=compressType,proto3" json:"compress_type,omitempty"` // 0:nocompress 1:Snappy 2:gzip CorrelationId int64 `protobuf:"varint,4,opt,name=correlation_id,json=correlationId,proto3" json:"correlation_id,omitempty"` AttachmentSize int32 `protobuf:"varint,5,opt,name=attachment_size,json=attachmentSize,proto3" json:"attachment_size,omitempty"` ChuckInfo *ChunkInfo `protobuf:"bytes,6,opt,name=chuck_info,json=chuckInfo,proto3" json:"chuck_info,omitempty"` AuthenticationData []byte `protobuf:"bytes,7,opt,name=authentication_data,json=authenticationData,proto3" json:"authentication_data,omitempty"` // contains filtered or unexported fields }
func (*RpcMeta) Descriptor
deprecated
func (*RpcMeta) GetAttachmentSize ¶
func (*RpcMeta) GetAuthenticationData ¶
func (*RpcMeta) GetChuckInfo ¶ added in v1.3.0
func (*RpcMeta) GetCompressType ¶
func (*RpcMeta) GetCorrelationId ¶
func (*RpcMeta) GetRequest ¶
func (*RpcMeta) GetResponse ¶
func (*RpcMeta) ProtoMessage ¶
func (*RpcMeta) ProtoMessage()
func (*RpcMeta) ProtoReflect ¶ added in v1.3.0
func (x *RpcMeta) ProtoReflect() protoreflect.Message
type RpcRequestMetaExtField ¶ added in v1.1.1
type RpcRequestMetaExtField struct { Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` // contains filtered or unexported fields }
func (*RpcRequestMetaExtField) Descriptor
deprecated
added in
v1.3.0
func (*RpcRequestMetaExtField) Descriptor() ([]byte, []int)
Deprecated: Use RpcRequestMetaExtField.ProtoReflect.Descriptor instead.
func (*RpcRequestMetaExtField) GetKey ¶ added in v1.1.1
func (x *RpcRequestMetaExtField) GetKey() string
func (*RpcRequestMetaExtField) GetValue ¶ added in v1.1.1
func (x *RpcRequestMetaExtField) GetValue() string
func (*RpcRequestMetaExtField) ProtoMessage ¶ added in v1.1.1
func (*RpcRequestMetaExtField) ProtoMessage()
func (*RpcRequestMetaExtField) ProtoReflect ¶ added in v1.3.0
func (x *RpcRequestMetaExtField) ProtoReflect() protoreflect.Message
func (*RpcRequestMetaExtField) Reset ¶ added in v1.1.1
func (x *RpcRequestMetaExtField) Reset()
func (*RpcRequestMetaExtField) String ¶ added in v1.1.1
func (x *RpcRequestMetaExtField) String() string
type RpcResult ¶ added in v1.1.1
type RpcResult struct {
// contains filtered or unexported fields
}
RpcResult Rpc response result from client request api under asynchronous way
func (*RpcResult) GetRpcDataPackage ¶ added in v1.1.1
func (rr *RpcResult) GetRpcDataPackage() *RpcDataPackage
type ServerMeta ¶
type Service ¶
type Service interface { /* RPC service call back method. message : parameter in from RPC client or 'nil' if has no parameter attachment : attachment content from RPC client or 'nil' if has no attachment logId : with a int64 type log sequence id from client or 'nil if has no logId return: [0] message return back to RPC client or 'nil' if need not return method response [1] attachment return back to RPC client or 'nil' if need not return attachemnt [2] return with any error or 'nil' represents success */ DoService(message proto.Message, attachment []byte, logId *int64) (proto.Message, []byte, error) GetServiceName() string GetMethodName() string NewParameter() proto.Message }
Service rpc service
type TCPConnection ¶
type TCPConnection struct {
// contains filtered or unexported fields
}
TCPConnection simple tcp based connection implementation
func NewTCPConnection ¶
func NewTCPConnection(url URL, timeout *time.Duration) (*TCPConnection, error)
Create a new TCPConnection and try to connect to target server by URL.
func (*TCPConnection) GetId ¶
func (c *TCPConnection) GetId() uint64
func (*TCPConnection) Receive ¶ added in v1.1.1
func (c *TCPConnection) Receive() (*RpcDataPackage, error)
Receive data from connection
func (*TCPConnection) Reconnect ¶ added in v1.2.1
func (c *TCPConnection) Reconnect() error
Reconnect do connect by saved info
func (*TCPConnection) Send ¶ added in v1.1.1
func (c *TCPConnection) Send(rpcDataPackage *RpcDataPackage) error
Send data to connection
func (*TCPConnection) SendReceive ¶
func (c *TCPConnection) SendReceive(rpcDataPackage *RpcDataPackage) (*RpcDataPackage, error)
SendReceive send data to connect and block wait data recevie
func (*TCPConnection) TestConnection ¶
func (c *TCPConnection) TestConnection() error
type TCPConnectionPool ¶
type TCPConnectionPool struct { Config *pool.ObjectPoolConfig // contains filtered or unexported fields }
func NewDefaultTCPConnectionPool ¶
func NewDefaultTCPConnectionPool(url URL, timeout *time.Duration) (*TCPConnectionPool, error)
func NewTCPConnectionPool ¶
func NewTCPConnectionPool(url URL, timeout *time.Duration, config *pool.ObjectPoolConfig) (*TCPConnectionPool, error)
func (*TCPConnectionPool) Close ¶
func (c *TCPConnectionPool) Close() error
func (*TCPConnectionPool) GetNumActive ¶
func (c *TCPConnectionPool) GetNumActive() int
func (*TCPConnectionPool) Receive ¶ added in v1.1.1
func (c *TCPConnectionPool) Receive() (*RpcDataPackage, error)
Receive
func (*TCPConnectionPool) Reconnect ¶ added in v1.2.1
func (c *TCPConnectionPool) Reconnect() error
Reconnect do connect by saved info
func (*TCPConnectionPool) Send ¶ added in v1.1.1
func (c *TCPConnectionPool) Send(rpcDataPackage *RpcDataPackage) error
Send
func (*TCPConnectionPool) SendReceive ¶
func (c *TCPConnectionPool) SendReceive(rpcDataPackage *RpcDataPackage) (*RpcDataPackage, error)
type TcpServer ¶
type TcpServer struct { EnablePerformanceLog bool // contains filtered or unexported fields }
TcpServer RPC server base on tcp transport
func (*TcpServer) RegisterName ¶
RegisterName register publishes in the server with specified name for its set of methods of the receiver value that satisfy the following conditions:
- exported method of exported type
- one argument, exported type and should be the type implements from proto.Message
- one return value, of type proto.Message
It returns an error if the receiver is not an exported type or has no suitable methods. It also logs the error using package log. The client accesses each method using a string of the form "Type.Method", where Type is the receiver's concrete type.
func (*TcpServer) RegisterNameWithMethodMapping ¶
func (s *TcpServer) RegisterNameWithMethodMapping(name string, rcvr interface{}, mapping map[string]string) (bool, error)
RegisterNameWithMethodMapping call RegisterName with method name mapping map
func (*TcpServer) RegisterRpc ¶
func (s *TcpServer) RegisterRpc(sname, mname string, callback RPCFN, inType proto.Message) (bool, error)
RegisterRpc register Rpc direct
func (*TcpServer) SetAuthService ¶ added in v1.1.1
func (s *TcpServer) SetAuthService(authservice AuthService)
SetAuthService set authenticate service
func (*TcpServer) SetTraceService ¶ added in v1.1.1
func (s *TcpServer) SetTraceService(traceService TraceService)
SetTraceService set trace service
func (*TcpServer) StartAndBlock ¶
func (*TcpServer) StartServer ¶ added in v1.0.8
StartServer start server with net.Listener
type TraceService ¶ added in v1.1.1
TraceService to monitor trace info and return trace info back