mirror of https://github.com/hashicorp/consul
feat: add no-op reporting background routine (#17178)
parent
0fc4fc6429
commit
ef5d54fd4c
|
@ -5,19 +5,26 @@ package reporting
|
|||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/consul/agent/consul/state"
|
||||
"github.com/hashicorp/consul/agent/structs"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/go-memdb"
|
||||
)
|
||||
|
||||
type ReportingManager struct {
|
||||
logger hclog.Logger
|
||||
server ServerDelegate
|
||||
logger hclog.Logger
|
||||
server ServerDelegate
|
||||
stateProvider StateDelegate
|
||||
tickerInterval time.Duration
|
||||
EntDeps
|
||||
sync.RWMutex
|
||||
}
|
||||
|
||||
const (
|
||||
SystemMetadataReportingProcessID = "reporting-process-id"
|
||||
ReportingInterval = 1 * time.Hour
|
||||
)
|
||||
|
||||
//go:generate mockery --name ServerDelegate --inpackage
|
||||
|
@ -27,10 +34,17 @@ type ServerDelegate interface {
|
|||
IsLeader() bool
|
||||
}
|
||||
|
||||
func NewReportingManager(logger hclog.Logger, deps EntDeps, server ServerDelegate) *ReportingManager {
|
||||
type StateDelegate interface {
|
||||
NodeUsage() (uint64, state.NodeUsage, error)
|
||||
ServiceUsage(ws memdb.WatchSet) (uint64, structs.ServiceUsage, error)
|
||||
}
|
||||
|
||||
func NewReportingManager(logger hclog.Logger, deps EntDeps, server ServerDelegate, stateProvider StateDelegate) *ReportingManager {
|
||||
rm := &ReportingManager{
|
||||
logger: logger.Named("reporting"),
|
||||
server: server,
|
||||
logger: logger.Named("reporting"),
|
||||
server: server,
|
||||
stateProvider: stateProvider,
|
||||
tickerInterval: ReportingInterval,
|
||||
}
|
||||
err := rm.initEnterpriseReporting(deps)
|
||||
if err != nil {
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
|
||||
package reporting
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type EntDeps struct{}
|
||||
|
||||
func (rm *ReportingManager) initEnterpriseReporting(entDeps EntDeps) error {
|
||||
|
@ -22,3 +26,7 @@ func (rm *ReportingManager) StopReportingAgent() error {
|
|||
// no op
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ReportingManager) Run(ctx context.Context) {
|
||||
// no op
|
||||
}
|
||||
|
|
|
@ -769,7 +769,8 @@ func NewServer(config *Config, flat Deps, externalGRPCServer *grpc.Server, incom
|
|||
s.overviewManager = NewOverviewManager(s.logger, s.fsm, s.config.MetricsReportingInterval)
|
||||
go s.overviewManager.Run(&lib.StopChannelContext{StopCh: s.shutdownCh})
|
||||
|
||||
s.reportingManager = reporting.NewReportingManager(s.logger, getEnterpriseReportingDeps(flat), s)
|
||||
s.reportingManager = reporting.NewReportingManager(s.logger, getEnterpriseReportingDeps(flat), s, s.fsm.State())
|
||||
go s.reportingManager.Run(&lib.StopChannelContext{StopCh: s.shutdownCh})
|
||||
|
||||
// Initialize external gRPC server
|
||||
s.setupExternalGRPC(config, logger)
|
||||
|
|
Loading…
Reference in New Issue