Help us shape the future of Go! Take the 2026 Go Developer Survey

client

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2025 License: MPL-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMetricsClient

func NewMetricsClient(ctx context.Context, cfg CloudConfig) (telemetry.MetricsClient, error)

NewMetricsClient returns a configured MetricsClient. The current implementation uses otlpClient to provide retry functionality.

Types

type BootstrapConfig

type BootstrapConfig struct {
	Name            string
	BootstrapExpect int
	GossipKey       string
	TLSCert         string
	TLSCertKey      string
	TLSCAs          []string
	ConsulConfig    string
	ManagementToken string
}

type CertificateMetadata

type CertificateMetadata struct {
	CertExpiry time.Time
	CertName   string
	CertSerial string
}

CertificateMetadata mirrors HashicorpCloudGlobalNetworkManager20220215CertificateMetadata

type Client

type Client interface {
	FetchBootstrap(ctx context.Context) (*BootstrapConfig, error)
	FetchTelemetryConfig(ctx context.Context) (*TelemetryConfig, error)
	PushServerStatus(ctx context.Context, status *ServerStatus) error
	DiscoverServers(ctx context.Context) ([]string, error)
}

Client interface exposes HCP operations that can be invoked by Consul

func NewClient

func NewClient(cfg config.CloudConfig) (Client, error)

type CloudConfig

type CloudConfig interface {
	HCPConfig(opts ...hcpcfg.HCPConfigOption) (hcpcfg.HCPConfig, error)
	Resource() (resource.Resource, error)
}

cloudConfig represents cloud config for TLS abstracted in an interface for easy testing.

type MetricsConfig

type MetricsConfig struct {
	Labels   map[string]string
	Filters  *regexp.Regexp
	Endpoint *url.URL
}

MetricsConfig holds metrics specific configuration within TelemetryConfig.

type MockClient

type MockClient struct {
	mock.Mock
}

MockClient is an autogenerated mock type for the Client type

func NewMockClient

func NewMockClient(t mockConstructorTestingTNewMockClient) *MockClient

NewMockClient creates a new instance of MockClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockClient) DiscoverServers

func (_m *MockClient) DiscoverServers(ctx context.Context) ([]string, error)

DiscoverServers provides a mock function with given fields: ctx

func (*MockClient) EXPECT

func (_m *MockClient) EXPECT() *MockClient_Expecter

func (*MockClient) FetchBootstrap

func (_m *MockClient) FetchBootstrap(ctx context.Context) (*BootstrapConfig, error)

FetchBootstrap provides a mock function with given fields: ctx

func (*MockClient) FetchTelemetryConfig

func (_m *MockClient) FetchTelemetryConfig(ctx context.Context) (*TelemetryConfig, error)

FetchTelemetryConfig provides a mock function with given fields: ctx

func (*MockClient) PushServerStatus

func (_m *MockClient) PushServerStatus(ctx context.Context, status *ServerStatus) error

PushServerStatus provides a mock function with given fields: ctx, status

type MockClient_DiscoverServers_Call

type MockClient_DiscoverServers_Call struct {
	*mock.Call
}

MockClient_DiscoverServers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DiscoverServers'

func (*MockClient_DiscoverServers_Call) Return

func (*MockClient_DiscoverServers_Call) Run

func (*MockClient_DiscoverServers_Call) RunAndReturn

type MockClient_Expecter

type MockClient_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockClient_Expecter) DiscoverServers

func (_e *MockClient_Expecter) DiscoverServers(ctx interface{}) *MockClient_DiscoverServers_Call

DiscoverServers is a helper method to define mock.On call

  • ctx context.Context

func (*MockClient_Expecter) FetchBootstrap

func (_e *MockClient_Expecter) FetchBootstrap(ctx interface{}) *MockClient_FetchBootstrap_Call

FetchBootstrap is a helper method to define mock.On call

  • ctx context.Context

func (*MockClient_Expecter) FetchTelemetryConfig

func (_e *MockClient_Expecter) FetchTelemetryConfig(ctx interface{}) *MockClient_FetchTelemetryConfig_Call

FetchTelemetryConfig is a helper method to define mock.On call

  • ctx context.Context

func (*MockClient_Expecter) PushServerStatus

func (_e *MockClient_Expecter) PushServerStatus(ctx interface{}, status interface{}) *MockClient_PushServerStatus_Call

PushServerStatus is a helper method to define mock.On call

  • ctx context.Context
  • status *ServerStatus

type MockClient_FetchBootstrap_Call

type MockClient_FetchBootstrap_Call struct {
	*mock.Call
}

MockClient_FetchBootstrap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FetchBootstrap'

func (*MockClient_FetchBootstrap_Call) Return

func (*MockClient_FetchBootstrap_Call) Run

func (*MockClient_FetchBootstrap_Call) RunAndReturn

type MockClient_FetchTelemetryConfig_Call

type MockClient_FetchTelemetryConfig_Call struct {
	*mock.Call
}

MockClient_FetchTelemetryConfig_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FetchTelemetryConfig'

func (*MockClient_FetchTelemetryConfig_Call) Return

func (*MockClient_FetchTelemetryConfig_Call) Run

func (*MockClient_FetchTelemetryConfig_Call) RunAndReturn

type MockClient_PushServerStatus_Call

type MockClient_PushServerStatus_Call struct {
	*mock.Call
}

MockClient_PushServerStatus_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PushServerStatus'

func (*MockClient_PushServerStatus_Call) Return

func (*MockClient_PushServerStatus_Call) Run

func (*MockClient_PushServerStatus_Call) RunAndReturn

type MockCloudCfg

type MockCloudCfg struct {
	ConfigErr   error
	ResourceErr error
}

func (MockCloudCfg) HCPConfig

func (m MockCloudCfg) HCPConfig(opts ...hcpcfg.HCPConfigOption) (hcpcfg.HCPConfig, error)

func (MockCloudCfg) Resource

func (m MockCloudCfg) Resource() (resource.Resource, error)

type RefreshConfig

type RefreshConfig struct {
	RefreshInterval time.Duration
}

RefreshConfig contains configuration for the periodic fetch of configuration from HCP.

type ServerACLInfo

type ServerACLInfo struct {
	Enabled bool
}

type ServerAutopilot

type ServerAutopilot struct {
	FailureTolerance int
	Healthy          bool
	MinQuorum        int
	NumServers       int
	NumVoters        int
}

type ServerRaft

type ServerRaft struct {
	IsLeader             bool
	KnownLeader          bool
	AppliedIndex         uint64
	TimeSinceLastContact time.Duration
}

type ServerStatus

type ServerStatus struct {
	ID         string
	Name       string
	Version    string
	LanAddress string
	GossipPort int
	RPCPort    int
	Datacenter string

	Autopilot         ServerAutopilot
	Raft              ServerRaft
	ACL               ServerACLInfo
	ServerTLSMetadata ServerTLSMetadata

	// TODO: TLS will be deprecated in favor of ServerTLSInfo in GNM. Handle
	// removal in a subsequent PR
	// https://hashicorp.atlassian.net/browse/CC-7015
	TLS ServerTLSInfo

	ScadaStatus string
}

ServerStatus is used to collect server status information in order to push to HCP. Fields should mirror HashicorpCloudGlobalNetworkManager20220215ServerState

type ServerTLSInfo

type ServerTLSInfo struct {
	Enabled                bool
	CertExpiry             time.Time
	CertIssuer             string
	CertName               string
	CertSerial             string
	CertificateAuthorities []CertificateMetadata
	VerifyIncoming         bool
	VerifyOutgoing         bool
	VerifyServerHostname   bool
}

ServerTLSInfo mirrors HashicorpCloudGlobalNetworkManager20220215TLSInfo

type ServerTLSMetadata

type ServerTLSMetadata struct {
	InternalRPC ServerTLSInfo
}

ServerTLSMetadata mirrors HashicorpCloudGlobalNetworkManager20220215ServerTLSMetadata

type TelemetryConfig

type TelemetryConfig struct {
	MetricsConfig *MetricsConfig
	RefreshConfig *RefreshConfig
}

TelemetryConfig contains configuration for telemetry data forwarded by Consul servers to the HCP Telemetry gateway.

func (*TelemetryConfig) MetricsEnabled

func (t *TelemetryConfig) MetricsEnabled() bool

MetricsEnabled returns true if metrics export is enabled, i.e. a valid metrics endpoint exists.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL