-
Notifications
You must be signed in to change notification settings - Fork 29
/
api.go
36 lines (29 loc) · 1.22 KB
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package api
import (
"github.com/go-kratos/kratos/v2/log"
"github.com/go-kratos/kratos/v2/registry"
grpc2 "github.com/go-kratos/kratos/v2/transport/grpc"
"github.com/go-kratos/kratos/v2/transport/http"
"github.com/go-saas/kit/pkg/api"
"github.com/go-saas/kit/pkg/conf"
v1 "github.com/go-saas/kit/saas/api/tenant/v1"
_ "github.com/go-saas/kit/saas/i18n"
"github.com/google/wire"
"google.golang.org/grpc"
)
type GrpcConn grpc.ClientConnInterface
type HttpClient *http.Client
const ServiceName = "saas"
func NewGrpcConn(clientName api.ClientName, services *conf.Services, dis registry.Discovery,
opt *api.Option, tokenMgr api.TokenManager,
logger log.Logger,
opts ...grpc2.ClientOption) (GrpcConn, func()) {
return api.NewGrpcConn(clientName, ServiceName, services, dis, opt, tokenMgr, logger, opts...)
}
var GrpcProviderSet = wire.NewSet(NewTenantStore, NewGrpcConn, NewTenantGrpcClient, NewTenantInternalGrpcClient)
func NewTenantGrpcClient(conn GrpcConn) v1.TenantServiceServer {
return v1.NewTenantServiceClientProxy(v1.NewTenantServiceClient(conn))
}
func NewTenantInternalGrpcClient(conn GrpcConn) v1.TenantInternalServiceServer {
return v1.NewTenantInternalServiceClientProxy(v1.NewTenantInternalServiceClient(conn))
}