saMicro

package
v0.0.0-...-b2602dc Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeResponse

func DecodeResponse(_ context.Context, response interface{}) (interface{}, error)

func EncodeRequest

func EncodeRequest(_ context.Context, request interface{}) (interface{}, error)

func InitServer

func InitServer(address string) error

func MakeApiEndPoint

func MakeApiEndPoint(s Service) endpoint.Endpoint

func NewGRPCServer

func NewGRPCServer(endpoint ApiEndPoint) proto.ApiServer

func RegisterHandlers

func RegisterHandlers(handlers map[string]Handler)

func RequestGrpcApi

func RequestGrpcApi(_ context.Context, grpcReq interface{}) (interface{}, error)

func ResponseGrpcApi

func ResponseGrpcApi(_ context.Context, response interface{}) (interface{}, error)

Types

type ApiEndPoint

type ApiEndPoint struct {
	EndPoint endpoint.Endpoint
}

func NewEndPointServer

func NewEndPointServer(svc Service, limit *rate.Limiter) ApiEndPoint

func (ApiEndPoint) Api

type Handler

type Handler func(ctx context.Context, in *Request) (ack *Response, err error)

type Request

type Request struct {
	Method string
	Data   string
}

type Response

type Response struct {
	Data string
}

type Service

type Service interface {
	Api(ctx context.Context, in *proto.Request) (ack *proto.Response, err error) //RPC服务接口方法
}

func InitClient

func InitClient(address string) (cl Service, err error)

func NewGRPCClient

func NewGRPCClient(conn *grpc.ClientConn) Service

func NewService

func NewService() Service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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