open-consul/agent/consul/reporting/reporting.go

42 lines
860 B
Go
Raw Normal View History

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
2023-04-18 15:03:05 +00:00
package reporting
import (
"sync"
"github.com/hashicorp/go-hclog"
)
type ReportingManager struct {
logger hclog.Logger
server ServerDelegate
EntDeps
sync.RWMutex
}
const (
SystemMetadataReportingProcessID = "reporting-process-id"
)
//go:generate mockery --name ServerDelegate --inpackage
type ServerDelegate interface {
GetSystemMetadata(key string) (string, error)
SetSystemMetadataKey(key, val string) error
IsLeader() bool
}
func NewReportingManager(logger hclog.Logger, deps EntDeps, server ServerDelegate) *ReportingManager {
rm := &ReportingManager{
logger: logger.Named("reporting"),
server: server,
}
err := rm.initEnterpriseReporting(deps)
if err != nil {
rm.logger.Error("Error initializing reporting manager", "error", err)
return nil
}
return rm
}