cRpc

package module
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: MIT Imports: 18 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 ParseHostFunc added in v0.0.52

type ParseHostFunc func(ctx *gin.Context, app, service string) (host, uri string)

type RpcClientContainer

type RpcClientContainer struct {
	// contains filtered or unexported fields
}

func (*RpcClientContainer) Get

func (i *RpcClientContainer) Get(name string) any

func (*RpcClientContainer) GetGRPCConnection added in v0.4.0

func (i *RpcClientContainer) GetGRPCConnection(pkg, app, name string) grpc.ClientConnInterface

func (*RpcClientContainer) GetHost added in v0.0.5

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

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(f func(instance 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) Listen added in v0.4.0

func (i *RpcComponent) Listen() []*cComponents.ConfigListener

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"`
	HostFunc        ParseHostFunc        `json:"-"`
	SignEncryptFunc SignatureEncryptFunc `json:"-"`
	SignDecryptFunc SignatureDecryptFunc `json:"-"`
}

func (*RpcConf) ConfigName

func (i *RpcConf) ConfigName() string

func (*RpcConf) Init added in v0.4.0

func (i *RpcConf) Init()

func (*RpcConf) SetHostFunc added in v0.4.0

func (i *RpcConf) SetHostFunc(f ParseHostFunc)

func (*RpcConf) SetSignDecryptFunc added in v0.4.0

func (i *RpcConf) SetSignDecryptFunc(f SignatureDecryptFunc)

func (*RpcConf) SetSignEncryptFunc added in v0.4.0

func (i *RpcConf) SetSignEncryptFunc(f SignatureEncryptFunc)

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 RpcController

type RpcController struct{}

func (*RpcController) ControllerName

func (i *RpcController) ControllerName() (app, name string)

func (*RpcController) Handler added in v0.0.12

func (i *RpcController) Handler(ctx *gin.Context) (err error)

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(f func(instance 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)
}

type SignatureDecryptFunc added in v0.4.0

type SignatureDecryptFunc func(ctx *gin.Context, app, service string) bool

type SignatureEncryptFunc added in v0.4.0

type SignatureEncryptFunc func(ctx *gin.Context, app, service string) string

Jump to

Keyboard shortcuts

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