From 339686ecf2806070d93dbeb4aa38d6dc40359632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Can=CC=83ete?= Date: Sat, 5 Nov 2022 11:25:23 +0100 Subject: [PATCH] add constants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Cañete --- pkg/scalers/nats_jetstream_scaler.go | 11 ++++++----- pkg/scalers/stan_scaler.go | 10 ++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pkg/scalers/nats_jetstream_scaler.go b/pkg/scalers/nats_jetstream_scaler.go index 01393555e57..6387f59f127 100644 --- a/pkg/scalers/nats_jetstream_scaler.go +++ b/pkg/scalers/nats_jetstream_scaler.go @@ -19,9 +19,10 @@ import ( ) const ( - jetStreamMetricType = "External" - defaultJetStreamLagThreshold = 10 - defaultNatsMonitoringEndpointProtocol = "http" + jetStreamMetricType = "External" + defaultJetStreamLagThreshold = 10 + natsHttpProtocol = "http" + natsHttpsProtocol = "https" ) type natsJetStreamScaler struct { @@ -164,9 +165,9 @@ func parseNATSJetStreamMetadata(config *ScalerConfig) (natsJetStreamMetadata, er } func (s *natsJetStreamScaler) getNATSJetStreamEndpoint() string { - protocol := "http" + protocol := natsHttpProtocol if s.metadata.useHttps { - protocol = "https" + protocol = natsHttpsProtocol } return fmt.Sprintf("%s://%s/jsz?acc=%s&consumers=true&config=true", protocol, s.metadata.monitoringEndpoint, s.metadata.account) } diff --git a/pkg/scalers/stan_scaler.go b/pkg/scalers/stan_scaler.go index 93faa463e93..97896830821 100644 --- a/pkg/scalers/stan_scaler.go +++ b/pkg/scalers/stan_scaler.go @@ -56,8 +56,10 @@ type stanMetadata struct { } const ( - stanMetricType = "External" - defaultStanLagThreshold = 10 + stanMetricType = "External" + defaultStanLagThreshold = 10 + natsStreamingHttpProtocol = "http" + natsStreamingHttpsProtocol = "https" ) // NewStanScaler creates a new stanScaler @@ -179,9 +181,9 @@ func (s *stanScaler) IsActive(ctx context.Context) (bool, error) { } func (s *stanScaler) getSTANChannelsEndpoint() string { - protocol := "http" + protocol := natsStreamingHttpProtocol if s.metadata.useHttps { - protocol = "https" + protocol = natsStreamingHttpsProtocol } return fmt.Sprintf("%s://%s/streaming/channelsz", protocol, s.metadata.natsServerMonitoringEndpoint) }