Skip to content

Commit

Permalink
add constants
Browse files Browse the repository at this point in the history
Signed-off-by: Manuel Cañete <mcaneteubeda@gmail.com>
  • Loading branch information
mknet3 committed Nov 5, 2022
1 parent 1f2764f commit 339686e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
11 changes: 6 additions & 5 deletions pkg/scalers/nats_jetstream_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import (
)

const (
jetStreamMetricType = "External"
defaultJetStreamLagThreshold = 10
defaultNatsMonitoringEndpointProtocol = "http"
jetStreamMetricType = "External"
defaultJetStreamLagThreshold = 10
natsHttpProtocol = "http"
natsHttpsProtocol = "https"
)

type natsJetStreamScaler struct {
Expand Down Expand Up @@ -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)
}
Expand Down
10 changes: 6 additions & 4 deletions pkg/scalers/stan_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 339686e

Please sign in to comment.