Skip to content

Commit

Permalink
PRint config on start-up
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Feb 21, 2020
1 parent 98e1110 commit 7973e78
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
7 changes: 5 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (
"time"
)

const defaultRebuild = time.Second * 3
const defaultUpstreamTimeout = time.Second * 60

// Config for the NATS Connector
type Config struct {
Broker string
Expand Down Expand Up @@ -49,8 +52,8 @@ func Get() Config {
gatewayURL = val
}

upstreamTimeout := time.Second * 30
rebuildInterval := time.Second * 3
upstreamTimeout := defaultUpstreamTimeout
rebuildInterval := defaultRebuild

if val, exists := os.LookupEnv("upstream_timeout"); exists {
parsedVal, err := time.ParseDuration(val)
Expand Down
21 changes: 21 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
package main

import (
"fmt"
"log"
"strconv"

"github.com/openfaas-incubator/connector-sdk/types"
"github.com/openfaas-incubator/nats-connector/config"
Expand Down Expand Up @@ -34,6 +36,25 @@ func main() {
ConnTimeout: config.UpstreamTimeout, // ConnTimeout isn't the same as UpstreamTimeout, it's just the delay to connect to NATS.
}

fmt.Printf(`==============================================================================
NATS Connector for OpenFaaS
Gateway URL: %s
NATS URL: nats://%s:4222
Topics: %s
Upstream timeout: %s
Topic-map rebuild interval: %s
Async invocation: %q
==============================================================================
`, config.GatewayURL,
config.Broker,
config.UpstreamTimeout,
config.Topics,
config.RebuildInterval,
strconv.FormatBool(config.AsyncFunctionInvocation),
)

broker, err := nats.NewBroker(brokerConfig)

if err != nil {
Expand Down

0 comments on commit 7973e78

Please sign in to comment.