Skip to content

Commit

Permalink
Fix temporal namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
benbjohnson committed Apr 10, 2024
1 parent 80e59a1 commit e0041a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
1 change: 1 addition & 0 deletions cmd/fly-autoscaler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ func NewConfigFromEnv() (*Config, error) {
c.MetricCollectors = append(c.MetricCollectors, &MetricCollectorConfig{
Type: "temporal",
Address: addr,
Namespace: os.Getenv("FAS_TEMPORAL_NAMESPACE"),
MetricName: os.Getenv("FAS_TEMPORAL_METRIC_NAME"),
CertData: certData,
KeyData: keyData,
Expand Down
24 changes: 11 additions & 13 deletions temporal/temporal.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package temporal
import (
"context"
"crypto/tls"
"fmt"
"log/slog"

Check failure on line 7 in temporal/temporal.go

View workflow job for this annotation

GitHub Actions / Unit Tests

"log/slog" imported and not used

Check failure on line 7 in temporal/temporal.go

View workflow job for this annotation

GitHub Actions / Integration Tests

"log/slog" imported and not used

Check failure on line 7 in temporal/temporal.go

View workflow job for this annotation

GitHub Actions / Build

"log/slog" imported and not used

Check failure on line 7 in temporal/temporal.go

View workflow job for this annotation

GitHub Actions / Staticcheck

"log/slog" imported and not used (compile)

"github.com/superfly/fly-autoscaler"
Expand All @@ -16,16 +17,13 @@ type MetricCollector struct {
name string
client client.Client

// Host & port of the Temporal server. Defaults to localhost:7233.
// Must be set before calling Open().
// Host & port of the Temporal server. Must be set before calling Open().
Address string

// Namespace to connect to. Defaults to "default".
// Must be set before calling Open().
// Namespace to connect to. Must be set before calling Open().
Namespace string

// Certificate & key data. Optional.
// Must be set before calling Open().
// Certificate & key data. Optional. Must be set before calling Open().
Cert []byte
Key []byte

Expand All @@ -38,18 +36,18 @@ func NewMetricCollector(name string) *MetricCollector {
}

func (c *MetricCollector) Open() (err error) {
if c.Address == "" {
return fmt.Errorf("temporal address required")
}
if c.Namespace == "" {
return fmt.Errorf("temporal namespace required")
}

opt := client.Options{
HostPort: c.Address,
Namespace: c.Namespace,
}

slog.Info("connecting to temporal",
slog.String("address", c.Address),
slog.String("namespace", c.Namespace),
slog.String("cert", string(c.Cert)),
slog.String("key", string(c.Key)),
slog.String("query", c.Query))

if len(c.Cert) != 0 || len(c.Key) != 0 {
cert, err := tls.X509KeyPair(c.Cert, c.Key)
if err != nil {
Expand Down

0 comments on commit e0041a6

Please sign in to comment.