open-consul/agent/grpc/public/services/serverdiscovery/server.go

39 lines
854 B
Go

package serverdiscovery
import (
"google.golang.org/grpc"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/consul/acl"
"github.com/hashicorp/consul/agent/consul/stream"
"github.com/hashicorp/consul/proto-public/pbserverdiscovery"
)
type Server struct {
Config
}
type Config struct {
Publisher EventPublisher
Logger hclog.Logger
ACLResolver ACLResolver
}
type EventPublisher interface {
Subscribe(*stream.SubscribeRequest) (*stream.Subscription, error)
}
//go:generate mockery -name ACLResolver -inpkg
type ACLResolver interface {
ResolveTokenAndDefaultMeta(string, *acl.EnterpriseMeta, *acl.AuthorizerContext) (acl.Authorizer, error)
}
func NewServer(cfg Config) *Server {
return &Server{cfg}
}
func (s *Server) Register(grpcServer *grpc.Server) {
pbserverdiscovery.RegisterServerDiscoveryServiceServer(grpcServer, s)
}