SpringRpc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2019 License: Apache-2.0 Imports: 1 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ERROR   = &RpcError{-1, "ERROR"}
	SUCCESS = &RpcError{200, "SUCCESS"}
)

Functions

This section is empty.

Types

type Handler

type Handler func(RpcContext) interface{}

type RpcBeanInitialization

type RpcBeanInitialization interface {
	InitRpcBean(c RpcContainer)
}

RPC Bean 初始化

type RpcContainer

type RpcContainer interface {
	Stop()

	Start(address string) error
	StartTLS(address string, certFile, keyFile string) error

	// 注册 RPC 方法(服务名+方法名)
	Register(service string, method string, fn Handler)
}

RPC 服务器

type RpcContext

type RpcContext interface {
	SpringTrace.TraceContext

	Bind(i interface{}) error

	// Get retrieves data from the context.
	Get(key string) interface{}

	// Set saves data in the context.
	Set(key string, val interface{})
}

RPC 上下文,务必保持是 WebContext 的子集!

type RpcError

type RpcError struct {
	Code int32  // 错误码
	Msg  string // 错误信息
}

RPC 错误值

func (*RpcError) Data

func (e *RpcError) Data(data interface{}) *RpcResult

func (*RpcError) Panic

func (e *RpcError) Panic(err error) *RpcPanic

type RpcPanic

type RpcPanic struct {
	Result *RpcResult
}

封装触发 panic 条件

func (*RpcPanic) When

func (p *RpcPanic) When(isPanic bool)

type RpcResult

type RpcResult struct {
	*RpcError

	Err  string      // 错误源
	Data interface{} // 返回值数据
}

RPC 返回值

Jump to

Keyboard shortcuts

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