Documentation ¶
Index ¶
- Constants
- Variables
- func GRPCRequest[C any](ctx *gin.Context, client RpcClientInterface, ...) (rsp any, err error)
- func HTTPRequest(ctx *gin.Context, client RpcClientInterface, method string, req, rsp any) (err error)
- type ClientType
- type RpcClientContainer
- type RpcClientInterface
- type RpcComponent
- type RpcConf
- type RpcConf_Client
- type RpcConf_Client_Service
- type RpcServiceContainer
- type RpcServiceInterface
Constants ¶
View Source
const ( RpcConfigName string = "RpcConf" GRPCClient ClientType = "grpc" HTTPClient ClientType = "http" HTTPRequestUri string = "/rpc/call" HTTPTimeout int64 = 60 HTTPTryTimes int64 = 3 )
Variables ¶
View Source
var Component = &RpcComponent{}
Functions ¶
func GRPCRequest ¶ added in v0.3.5
func GRPCRequest[C any](ctx *gin.Context, client RpcClientInterface, f func(cc grpc.ClientConnInterface) C, method string, req any) (rsp any, err error)
func HTTPRequest ¶ added in v0.3.5
Types ¶
type ClientType ¶ added in v0.3.2
type ClientType string
type RpcClientContainer ¶
type RpcClientContainer struct {
// contains filtered or unexported fields
}
func (*RpcClientContainer) Get ¶
func (i *RpcClientContainer) Get(name string) any
func (*RpcClientContainer) Is ¶ added in v0.4.0
func (i *RpcClientContainer) Is(instance any) bool
func (*RpcClientContainer) Range ¶ added in v0.4.0
func (i *RpcClientContainer) Range() chan any
func (*RpcClientContainer) Remove ¶ added in v0.4.0
func (i *RpcClientContainer) Remove(name string) bool
func (*RpcClientContainer) Save ¶
func (i *RpcClientContainer) Save(instance any) bool
type RpcClientInterface ¶
type RpcClientInterface interface {
RpcClientName() (pkg, app, service string)
}
type RpcComponent ¶ added in v0.3.9
type RpcComponent struct{}
func (*RpcComponent) Inject ¶ added in v0.3.9
func (i *RpcComponent) Inject(instance any) bool
func (*RpcComponent) InjectConf ¶ added in v0.4.0
func (i *RpcComponent) InjectConf(config cComponents.ConfigInterface) bool
func (*RpcComponent) Load ¶ added in v0.3.9
func (i *RpcComponent) Load()
type RpcConf ¶
type RpcConf struct { // 配置项 RequestURI string `json:"request_uri"` Timeout int64 `json:"timeout"` Try int64 `json:"try"` Signature string `json:"signature"` Clients []*RpcConf_Client `json:"clients"` // contains filtered or unexported fields }
func (*RpcConf) ConfigName ¶
type RpcConf_Client ¶ added in v0.0.6
type RpcConf_Client struct { Type ClientType `json:"type"` Host string `json:"host"` Package string `json:"package"` Services []*RpcConf_Client_Service `json:"services"` }
type RpcConf_Client_Service ¶ added in v0.0.6
type RpcServiceContainer ¶ added in v0.4.0
type RpcServiceContainer struct {
// contains filtered or unexported fields
}
func (*RpcServiceContainer) Get ¶ added in v0.4.0
func (i *RpcServiceContainer) Get(name string) any
func (*RpcServiceContainer) Is ¶ added in v0.4.0
func (i *RpcServiceContainer) Is(instance any) bool
func (*RpcServiceContainer) Range ¶ added in v0.4.0
func (i *RpcServiceContainer) Range() chan any
func (*RpcServiceContainer) Remove ¶ added in v0.4.0
func (i *RpcServiceContainer) Remove(name string) bool
func (*RpcServiceContainer) Save ¶ added in v0.4.0
func (i *RpcServiceContainer) Save(instance any) bool
type RpcServiceInterface ¶
type RpcServiceInterface interface {
RpcServiceName() (app, service string)
}
Click to show internal directories.
Click to hide internal directories.