|
|
|
@ -5,6 +5,7 @@ import (
|
|
|
|
|
"Open_IM/pkg/common/constant"
|
|
|
|
|
rocksCache "Open_IM/pkg/common/db/rocks_cache"
|
|
|
|
|
"Open_IM/pkg/common/log"
|
|
|
|
|
promePkg "Open_IM/pkg/common/prometheus"
|
|
|
|
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
|
|
|
|
pbCache "Open_IM/pkg/proto/cache"
|
|
|
|
|
"Open_IM/pkg/utils"
|
|
|
|
@ -13,6 +14,7 @@ import (
|
|
|
|
|
"strconv"
|
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -50,8 +52,18 @@ func (s *cacheServer) Run() {
|
|
|
|
|
log.NewInfo("0", "listen network success, ", address, listener)
|
|
|
|
|
defer listener.Close()
|
|
|
|
|
//grpc server
|
|
|
|
|
|
|
|
|
|
srv := grpc.NewServer()
|
|
|
|
|
var grpcOpts []grpc.ServerOption
|
|
|
|
|
if config.Config.Prometheus.Enable {
|
|
|
|
|
promePkg.NewGrpcRequestCounter()
|
|
|
|
|
promePkg.NewGrpcRequestFailedCounter()
|
|
|
|
|
promePkg.NewGrpcRequestSuccessCounter()
|
|
|
|
|
grpcOpts = append(grpcOpts, []grpc.ServerOption{
|
|
|
|
|
grpc.UnaryInterceptor(promePkg.UnaryServerInterceptorProme),
|
|
|
|
|
grpc.StreamInterceptor(grpcPrometheus.StreamServerInterceptor),
|
|
|
|
|
grpc.UnaryInterceptor(grpcPrometheus.UnaryServerInterceptor),
|
|
|
|
|
}...)
|
|
|
|
|
}
|
|
|
|
|
srv := grpc.NewServer(grpcOpts...)
|
|
|
|
|
defer srv.GracefulStop()
|
|
|
|
|
pbCache.RegisterCacheServer(srv, s)
|
|
|
|
|
|
|
|
|
|