Documentation ¶
Index ¶
Constants ¶
View Source
const ( TargetAddress = "rpc_target_address" RequestTimeoutMs = "rpc_request_timeout" )
View Source
const (
DefaultRequestTimeoutMs = 3000
)
View Source
const ServiceName = "rpc"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Callback ¶
type Callback interface { // AddBeforeInvoke is add BeforeInvoke func AddBeforeInvoke(CallbackFunc) // AddAfterInvoke is add AfterInvoke func AddAfterInvoke(CallbackFunc) // BeforeInvoke is used to invoke beforeInvoke callbacks BeforeInvoke(*RPCRequest) (*RPCRequest, error) // AfterInvoke is used to invoke afterInvoke callbacks AfterInvoke(*RPCResponse) (*RPCResponse, error) }
Callback is interface for before invoke or after invoke
type CallbackFunc ¶
type CallbackFunc struct { Name string `json:"name"` Config json.RawMessage `json:"config"` }
CallbackFunc is Callback implement
type Channel ¶
type Channel interface {
Do(*RPCRequest) (*RPCResponse, error)
}
Channel is handle RPCRequest to RPCResponse
type Factory ¶
type Factory struct { Name string Fm FactoryMethod }
Factory is NewRpcFactory implement
func NewRpcFactory ¶
func NewRpcFactory(name string, fm FactoryMethod) *Factory
NewRpcFactory is rpc create factory entrance
type FactoryMethod ¶
type FactoryMethod func() Invoker
type Invoker ¶
type Invoker interface { Init(config RpcConfig) error Invoke(ctx context.Context, req *RPCRequest) (*RPCResponse, error) }
Invoker is interface for init rpc config or invoke rpc request
type RPCRequest ¶
type RPCRequest struct { // context Ctx context.Context // request id Id string Timeout int32 Method string ContentType string Header RPCHeader Data []byte }
RPCRequest is request info
type RPCResponse ¶
type RPCResponse struct { Ctx context.Context Header RPCHeader ContentType string Data []byte Success bool Error error }
RPCResponse is response info
type Registry ¶
Registry is interface for registry
func NewRegistry ¶
func NewRegistry(info *info.RuntimeInfo) Registry
NewRegistry is init rpcRegistry
type RpcConfig ¶
type RpcConfig struct {
Config json.RawMessage
}
Click to show internal directories.
Click to hide internal directories.