2022-03-27 10:59:30 +00:00
|
|
|
package dataplane
|
|
|
|
|
|
|
|
import (
|
|
|
|
"google.golang.org/grpc"
|
2022-04-05 21:10:06 +00:00
|
|
|
|
2022-04-20 00:24:21 +00:00
|
|
|
"github.com/hashicorp/go-hclog"
|
|
|
|
|
2022-04-05 21:10:06 +00:00
|
|
|
"github.com/hashicorp/consul/acl"
|
2022-04-20 00:24:21 +00:00
|
|
|
"github.com/hashicorp/consul/agent/structs"
|
2022-04-05 21:10:06 +00:00
|
|
|
"github.com/hashicorp/consul/proto-public/pbdataplane"
|
2022-03-27 10:59:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Server struct {
|
|
|
|
Config
|
|
|
|
}
|
|
|
|
|
|
|
|
type Config struct {
|
2022-04-20 00:24:21 +00:00
|
|
|
GetStore func() StateStore
|
2022-03-27 10:59:30 +00:00
|
|
|
Logger hclog.Logger
|
|
|
|
ACLResolver ACLResolver
|
2022-04-20 00:24:21 +00:00
|
|
|
// Datacenter of the Consul server this gRPC server is hosted on
|
|
|
|
Datacenter string
|
|
|
|
}
|
|
|
|
|
|
|
|
type StateStore interface {
|
|
|
|
ServiceNode(string, string, string, *acl.EnterpriseMeta) (uint64, *structs.ServiceNode, error)
|
2022-03-27 10:59:30 +00:00
|
|
|
}
|
|
|
|
|
2022-04-21 14:48:21 +00:00
|
|
|
//go:generate mockery --name ACLResolver --inpackage
|
2022-03-27 10:59:30 +00:00
|
|
|
type ACLResolver interface {
|
2022-04-05 21:10:06 +00:00
|
|
|
ResolveTokenAndDefaultMeta(string, *acl.EnterpriseMeta, *acl.AuthorizerContext) (acl.Authorizer, error)
|
2022-03-27 10:59:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewServer(cfg Config) *Server {
|
|
|
|
return &Server{cfg}
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ pbdataplane.DataplaneServiceServer = (*Server)(nil)
|
|
|
|
|
|
|
|
func (s *Server) Register(grpcServer *grpc.Server) {
|
|
|
|
pbdataplane.RegisterDataplaneServiceServer(grpcServer, s)
|
|
|
|
}
|