grafana/pkg/services/store/entity/client_wrapper.go
Dan Cech 156d7ae194
use in-process grpc client instead of wrapping server interface (#81926)
* use in-process grpc client instead of wrapping server interface

* comment out jwt token checks until we're ready to validate the token
2024-02-07 13:17:02 -05:00

31 lines
982 B
Go

package entity
import (
"github.com/fullstorydev/grpchan"
"github.com/fullstorydev/grpchan/inprocgrpc"
grpcAuth "github.com/grpc-ecosystem/go-grpc-middleware/auth"
"google.golang.org/grpc"
grpcUtils "github.com/grafana/grafana/pkg/services/store/entity/grpc"
)
func NewEntityStoreClientLocal(server EntityStoreServer) EntityStoreClient {
channel := &inprocgrpc.Channel{}
auth := &grpcUtils.Authenticator{}
channel.RegisterService(
grpchan.InterceptServer(
&EntityStore_ServiceDesc,
grpcAuth.UnaryServerInterceptor(auth.Authenticate),
grpcAuth.StreamServerInterceptor(auth.Authenticate),
),
server,
)
return NewEntityStoreClient(grpchan.InterceptClientConn(channel, grpcUtils.UnaryClientInterceptor, grpcUtils.StreamClientInterceptor))
}
func NewEntityStoreClientGRPC(channel *grpc.ClientConn) EntityStoreClient {
return NewEntityStoreClient(grpchan.InterceptClientConn(channel, grpcUtils.UnaryClientInterceptor, grpcUtils.StreamClientInterceptor))
}