update
This commit is contained in:
parent
eaccbd34e4
commit
b4899db5b3
@ -1,55 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/auth"
|
||||
"github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/logging"
|
||||
"github.com/spf13/cobra"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/reflection"
|
||||
"leaf
|
||||
"net"
|
||||
)
|
||||
|
||||
func init() {
|
||||
RootCmd.AddCommand(documentServiceCommand)
|
||||
}
|
||||
|
||||
var documentServiceCommand = &cobra.Command{
|
||||
Use: "document",
|
||||
Short: "Start document service",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
app, err := CreateApp()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return
|
||||
}
|
||||
|
||||
app.Logger.Sugar.Info("Start document service")
|
||||
|
||||
lis, err := net.Listen("tcp", app.Config.Grpc.Address)
|
||||
if err != nil {
|
||||
app.Logger.Sugar.Fatal(err)
|
||||
}
|
||||
var opts = []grpc.ServerOption{
|
||||
grpc.ChainUnaryInterceptor(
|
||||
logging.UnaryServerInterceptor(app.Handler.GRPC.Interceptor.Logger.ZapLogInterceptor()),
|
||||
|
||||
auth.UnaryServerInterceptor(app.Handler.GRPC.Interceptor.Auth.JwtAuth),
|
||||
),
|
||||
grpc.ChainStreamInterceptor(
|
||||
logging.StreamServerInterceptor(app.Handler.GRPC.Interceptor.Logger.ZapLogInterceptor()),
|
||||
auth.StreamServerInterceptor(app.Handler.GRPC.Interceptor.Auth.JwtAuth),
|
||||
),
|
||||
}
|
||||
grpcServer := grpc.NewServer(opts...)
|
||||
|
||||
documentService.RegisterDocumentServiceServer(grpcServer, app.Handler.GRPC.DocumentService)
|
||||
reflection.Register(grpcServer)
|
||||
|
||||
app.Logger.Sugar.Info("Document Service listing on " + app.Config.Grpc.Address)
|
||||
|
||||
if err := grpcServer.Serve(lis); err != nil {
|
||||
app.Logger.Sugar.Fatal(err)
|
||||
}
|
||||
},
|
||||
}
|
@ -2,7 +2,6 @@ package base
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"leafdev.top/Leaf/api-platform/int
|
||||
"leafdev.top/Leaf/api-platform/internal/base/conf"
|
||||
"leafdev.top/Leaf/api-platform/internal/base/logger"
|
||||
"leafdev.top/Leaf/api-platform/internal/base/redis"
|
||||
@ -12,7 +11,7 @@ import (
|
||||
"leafdev.top/Leaf/api-platform/internal/dao"
|
||||
"leafdev.top/Leaf/api-platform/internal/handler"
|
||||
"leafdev.top/Leaf/api-platform/internal/handler/http"
|
||||
"gorm.io/gorm"
|
||||
"leafdev.top/Leaf/api-platform/internal/service"
|
||||
)
|
||||
|
||||
type Application struct {
|
||||
|
Loading…
Reference in New Issue
Block a user