2023-03-28 18:39:22 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2023-08-11 13:12:13 +00:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-03-28 18:39:22 +00:00
|
|
|
|
2022-03-27 10:59:30 +00:00
|
|
|
package dataplane
|
|
|
|
|
|
|
|
import (
|
2023-09-06 22:46:25 +00:00
|
|
|
"github.com/hashicorp/consul/proto-public/pbresource"
|
2022-03-27 10:59:30 +00:00
|
|
|
"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-10-10 17:40:27 +00:00
|
|
|
"github.com/hashicorp/go-memdb"
|
2022-04-20 00:24:21 +00:00
|
|
|
|
2022-04-05 21:10:06 +00:00
|
|
|
"github.com/hashicorp/consul/acl"
|
2022-06-17 09:24:43 +00:00
|
|
|
"github.com/hashicorp/consul/acl/resolver"
|
2022-10-10 17:40:27 +00:00
|
|
|
"github.com/hashicorp/consul/agent/configentry"
|
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
|
2023-09-06 22:46:25 +00:00
|
|
|
|
|
|
|
// EnableV2 indicates whether a feature flag for v2 APIs is provided.
|
|
|
|
EnableV2 bool
|
|
|
|
ResourceAPIClient pbresource.ResourceServiceClient
|
2022-04-20 00:24:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type StateStore interface {
|
peering: initial sync (#12842)
- Add endpoints related to peering: read, list, generate token, initiate peering
- Update node/service/check table indexing to account for peers
- Foundational changes for pushing service updates to a peer
- Plumb peer name through Health.ServiceNodes path
see: ENT-1765, ENT-1280, ENT-1283, ENT-1283, ENT-1756, ENT-1739, ENT-1750, ENT-1679,
ENT-1709, ENT-1704, ENT-1690, ENT-1689, ENT-1702, ENT-1701, ENT-1683, ENT-1663,
ENT-1650, ENT-1678, ENT-1628, ENT-1658, ENT-1640, ENT-1637, ENT-1597, ENT-1634,
ENT-1613, ENT-1616, ENT-1617, ENT-1591, ENT-1588, ENT-1596, ENT-1572, ENT-1555
Co-authored-by: R.B. Boyer <rb@hashicorp.com>
Co-authored-by: freddygv <freddy@hashicorp.com>
Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
Co-authored-by: Evan Culver <eculver@hashicorp.com>
Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
2022-04-21 22:34:40 +00:00
|
|
|
ServiceNode(string, string, string, *acl.EnterpriseMeta, string) (uint64, *structs.ServiceNode, error)
|
2022-10-10 17:40:27 +00:00
|
|
|
ReadResolvedServiceConfigEntries(memdb.WatchSet, string, *acl.EnterpriseMeta, []structs.ServiceID, structs.ProxyMode) (uint64, *configentry.ResolvedServiceConfigSet, 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-06-17 09:24:43 +00:00
|
|
|
ResolveTokenAndDefaultMeta(string, *acl.EnterpriseMeta, *acl.AuthorizerContext) (resolver.Result, error)
|
2022-03-27 10:59:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewServer(cfg Config) *Server {
|
|
|
|
return &Server{cfg}
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ pbdataplane.DataplaneServiceServer = (*Server)(nil)
|
|
|
|
|
2024-01-12 16:54:07 +00:00
|
|
|
func (s *Server) Register(registrar grpc.ServiceRegistrar) {
|
|
|
|
pbdataplane.RegisterDataplaneServiceServer(registrar, s)
|
2022-03-27 10:59:30 +00:00
|
|
|
}
|