2020-06-10 20:47:35 +00:00
|
|
|
package consul
|
|
|
|
|
|
|
|
import (
|
2021-04-20 22:14:46 +00:00
|
|
|
"github.com/hashicorp/go-hclog"
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
|
proxycfg: server-local config entry data sources
This is the OSS portion of enterprise PR 2056.
This commit provides server-local implementations of the proxycfg.ConfigEntry
and proxycfg.ConfigEntryList interfaces, that source data from streaming events.
It makes use of the LocalMaterializer type introduced for peering replication,
adding the necessary support for authorization.
It also adds support for "wildcard" subscriptions (within a topic) to the event
publisher, as this is needed to fetch service-resolvers for all services when
configuring mesh gateways.
Currently, events will be emitted for just the ingress-gateway, service-resolver,
and mesh config entry types, as these are the only entries required by proxycfg
— the events will be emitted on topics named IngressGateway, ServiceResolver,
and MeshConfig topics respectively.
Though these events will only be consumed "locally" for now, they can also be
consumed via the gRPC endpoint (confirmed using grpcurl) so using them from
client agents should be a case of swapping the LocalMaterializer for an
RPCMaterializer.
2022-07-01 15:09:47 +00:00
|
|
|
"github.com/hashicorp/consul-net-rpc/net/rpc"
|
|
|
|
|
|
|
|
"github.com/hashicorp/consul/agent/consul/stream"
|
2020-06-10 20:47:35 +00:00
|
|
|
"github.com/hashicorp/consul/agent/pool"
|
2020-08-27 15:23:52 +00:00
|
|
|
"github.com/hashicorp/consul/agent/router"
|
2022-04-06 21:33:05 +00:00
|
|
|
"github.com/hashicorp/consul/agent/rpc/middleware"
|
2020-06-10 20:47:35 +00:00
|
|
|
"github.com/hashicorp/consul/agent/token"
|
|
|
|
"github.com/hashicorp/consul/tlsutil"
|
|
|
|
)
|
|
|
|
|
2020-09-14 22:31:07 +00:00
|
|
|
type Deps struct {
|
proxycfg: server-local config entry data sources
This is the OSS portion of enterprise PR 2056.
This commit provides server-local implementations of the proxycfg.ConfigEntry
and proxycfg.ConfigEntryList interfaces, that source data from streaming events.
It makes use of the LocalMaterializer type introduced for peering replication,
adding the necessary support for authorization.
It also adds support for "wildcard" subscriptions (within a topic) to the event
publisher, as this is needed to fetch service-resolvers for all services when
configuring mesh gateways.
Currently, events will be emitted for just the ingress-gateway, service-resolver,
and mesh config entry types, as these are the only entries required by proxycfg
— the events will be emitted on topics named IngressGateway, ServiceResolver,
and MeshConfig topics respectively.
Though these events will only be consumed "locally" for now, they can also be
consumed via the gRPC endpoint (confirmed using grpcurl) so using them from
client agents should be a case of swapping the LocalMaterializer for an
RPCMaterializer.
2022-07-01 15:09:47 +00:00
|
|
|
EventPublisher *stream.EventPublisher
|
2020-09-14 22:31:07 +00:00
|
|
|
Logger hclog.InterceptLogger
|
|
|
|
TLSConfigurator *tlsutil.Configurator
|
|
|
|
Tokens *token.Store
|
|
|
|
Router *router.Router
|
|
|
|
ConnPool *pool.ConnPool
|
2021-04-20 22:14:46 +00:00
|
|
|
GRPCConnPool GRPCClientConner
|
2021-07-22 18:58:08 +00:00
|
|
|
LeaderForwarder LeaderForwarder
|
2022-04-06 21:33:05 +00:00
|
|
|
// GetNetRPCInterceptorFunc, if not nil, sets the net/rpc rpc.ServerServiceCallInterceptor on
|
|
|
|
// the server side to record metrics around the RPC requests. If nil, no interceptor is added to
|
|
|
|
// the rpc server.
|
|
|
|
GetNetRPCInterceptorFunc func(recorder *middleware.RequestRecorder) rpc.ServerServiceCallInterceptor
|
|
|
|
// NewRequestRecorderFunc provides a middleware.RequestRecorder for the server to use; it cannot be nil
|
2022-04-12 17:50:25 +00:00
|
|
|
NewRequestRecorderFunc func(logger hclog.Logger, isLeader func() bool, localDC string) *middleware.RequestRecorder
|
2021-05-11 14:50:03 +00:00
|
|
|
EnterpriseDeps
|
2021-04-20 22:14:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type GRPCClientConner interface {
|
|
|
|
ClientConn(datacenter string) (*grpc.ClientConn, error)
|
2021-07-22 18:58:08 +00:00
|
|
|
ClientConnLeader() (*grpc.ClientConn, error)
|
2021-08-24 21:28:44 +00:00
|
|
|
SetGatewayResolver(func(string) string)
|
2021-07-22 18:58:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type LeaderForwarder interface {
|
2021-08-24 21:28:44 +00:00
|
|
|
// UpdateLeaderAddr updates the leader address in the local DC's resolver.
|
|
|
|
UpdateLeaderAddr(datacenter, addr string)
|
2020-06-10 20:47:35 +00:00
|
|
|
}
|