Documentation
¶
Index ¶
- Constants
- Variables
- func GetProtocol(ContentType string) string
- func MatchCodec(protocol, codec string) bool
- type Component
- type ComponentBase
- type Endpoint
- type Module
- type Node
- type PreExecuteHook
- type Protocols
- type Registry
- type Request
- type Response
- type Result
- type Service
- type Stream
- type Target
- type Version
- type Watcher
Constants ¶
View Source
const ( NodeHeader = "X-Node-Id" // 限定 node TokenHeader = "X-Auth-Token" // 认证头 TokenScope = "X-Token-Scope" // token范围 TokenTenant = "X-Token-Tenant" // token限定租户范围 ContentType = "Content-Type" Accept = "Accept" Host = "Host" Tenant = "Tenant" PrimaryKey = "PrimaryKey" )
Variables ¶
View Source
var ( DefaultCodecs = map[string]string{ "text/html": "application/grpc+bytes", "text/plain": "application/grpc+bytes", "application/grpc+json": "application/grpc+json", "application/grpc+proto": "application/grpc+proto", "application/grpc+bytes": "application/grpc+bytes", "application/json": "application/grpc+json", "application/grpc": "application/grpc+proto", "application/protobuf": "application/grpc+proto", "application/octet-stream": "application/grpc+bytes", } DefaultContentType = "application/grpc+bytes" )
View Source
var ( // ErrIPNotFound no IP address found, and explicit IP not provided. ErrIPNotFound = errors.New("no IP address found, and explicit IP not provided") ErrConfigCountNotMatch = errors.New("config count not match") ErrHandlerFound = errors.New("handler not found") ErrMismatch = errors.New("value mismatch") ErrConfigFound = errors.New("config not found") ErrServiceNotFound = errors.New("service not found") ErrWatcherStopped = errors.New("watcher stopped") ErrSelectServiceNotFound = errors.New("no service found") ErrSelectEndpointNotFound = errors.New("endpoint not found") ErrNoneServiceAvailable = errors.New("none available") // node not found ErrResultFailed = errors.New("result failed") // node not found ErrUnknown = errors.New("unknown error") // node not found )
View Source
var ( NoVersion = errors.New("no version") VersionErr = errors.New("version value error") )
Functions ¶
func GetProtocol ¶
func MatchCodec ¶
Types ¶
type Component ¶
type Component interface { /* Init 初始化执行 */ Init() /* AfterInit 初始化完成后执行 */ AfterInit() /* BeforeShutdown 进程停止前时执行 */ BeforeShutdown() /* Shutdown 进程停止时执行 */ Shutdown() /* Name 组件对应Resource名 */ Name() string /* Collection 组件对应Collection名(resource的复数形式) */ Collection() string /* Hooks pre execute hook, nil able @method 原始方法名 */ Hooks(method string) []PreExecuteHook }
Component 通用api组件 1. Restful方法名 Get/List/Create/Update/Patch/Delete 2. 非Restful方法名 以 GET_/POST_/PUT_/PATCH_/DELETE_开头,其余部分小写为路径 e.g User.GET_Money, 路径为/user/money 3. 以RPC_开头的方法为内部rpc方法 4. 其他方法为注册到网关可转发方法(不可与3分割后同名) 5. 一般不建议在组件中设置生命周期方法,尽量在模块中做生命周期相关操作
type ComponentBase ¶
type ComponentBase struct{}
ComponentBase 通用组件继承
func (*ComponentBase) AfterInit ¶
func (*ComponentBase) AfterInit()
func (*ComponentBase) BeforeShutdown ¶
func (*ComponentBase) BeforeShutdown()
func (*ComponentBase) Hooks ¶
func (*ComponentBase) Hooks(_ string) []PreExecuteHook
func (*ComponentBase) Init ¶
func (*ComponentBase) Init()
func (*ComponentBase) Shutdown ¶
func (*ComponentBase) Shutdown()
type PreExecuteHook ¶
type Request ¶
type Request interface { // primary key PrimaryKey() string // The host to call Host() string // The service to call Service() string // The action to take Method() string // The endpoint to invoke Endpoint() string // The content type Protocols() *Protocols // Query string Query() url.Values // The unencoded request body Body() interface{} // service version fileter Version() *Version }
Request is the interface for a synchronous request used by Call or Stream.
type Stream ¶
type Stream interface { CloseSend() error // Send will encode and send a request Send(body []byte) error // Recv will decode and read a response Recv(string, *Response) error // Close closes the stream Close() error }
Stream is the inteface for a bidirectional synchronous stream.
type Version ¶
type Version struct { Major int `json:"major,omitempty"` Minor int `json:"minor,omitempty"` Patch int `json:"patch,omitempty"` }
func NewVersion ¶
func (Version) MarshalJSON ¶
MarshalJSON Implementing the json.Marshaler interface
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package client is an interface for an RPC client
|
Package client is an interface for an RPC client |
Package errors provides a way to return detailed information for an RPC request error.
|
Package errors provides a way to return detailed information for an RPC request error. |
cache
Package cache provides a registry cache
|
Package cache provides a registry cache |
Package transport is an interface for synchronous connection based communication
|
Package transport is an interface for synchronous connection based communication |
flock
Package flock implements a thread-safe interface for file locking.
|
Package flock implements a thread-safe interface for file locking. |
Click to show internal directories.
Click to hide internal directories.