cRpc

package module
v0.4.0-dev Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 15 Imported by: 1

Documentation

Index

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

func HTTPRequest(ctx *gin.Context, client RpcClientInterface, method string, req, rsp any) (err error)

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

func (i *RpcConf) ConfigName() string

func (*RpcConf) GetHost

func (i *RpcConf) GetHost(pkg, app, name string) (host string)

func (*RpcConf) Init added in v0.4.0

func (i *RpcConf) Init()

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 RpcConf_Client_Service struct {
	App     string `json:"app"`
	Service string `json:"service"`
}

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)
}

Jump to

Keyboard shortcuts

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