Ai
1 Star 0 Fork 0

saxon134/go-utils

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
endpoint.go 834 Bytes
一键复制 编辑 原始数据 按行查看 历史
saxon134 提交于 2023-10-03 16:56 +08:00 . init
package saMicro
import (
"context"
"fmt"
"gitee.com/saxon134/go-utils/saMicro/proto"
"github.com/go-kit/kit/endpoint"
"golang.org/x/time/rate"
)
type ApiEndPoint struct {
EndPoint endpoint.Endpoint
}
func NewEndPointServer(svc Service, limit *rate.Limiter) ApiEndPoint {
var apiEndPoint endpoint.Endpoint
{
apiEndPoint = MakeApiEndPoint(svc)
}
return ApiEndPoint{EndPoint: apiEndPoint}
}
func (s ApiEndPoint) Api(ctx context.Context, in *proto.Request) (*proto.Response, error) {
resp, err := s.EndPoint(ctx, in)
if err != nil {
fmt.Println("0:")
return nil, err
}
return resp.(*proto.Response), nil
}
func MakeApiEndPoint(s Service) endpoint.Endpoint {
return func(ctx context.Context, request interface{}) (response interface{}, err error) {
req := request.(*proto.Request)
return s.Api(ctx, req)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/saxon134/go-utils.git
git@gitee.com:saxon134/go-utils.git
saxon134
go-utils
go-utils
b2602dc8c3fc

搜索帮助