kopia lustrzana https://github.com/bugout-dev/moonstream
Manual brood client creation with timeout
rodzic
541779c0b5
commit
96886a56a0
|
@ -224,11 +224,7 @@ func cli() {
|
|||
}
|
||||
|
||||
// Init bugout client
|
||||
bc, err := bugout.ClientFromEnv()
|
||||
if err != nil {
|
||||
fmt.Printf("Unable to initialize bugout client, err: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
bc := CreateBugoutClient()
|
||||
bugoutClient = bc
|
||||
|
||||
// Parse subcommands and appropriate FlagSet
|
||||
|
|
|
@ -10,9 +10,11 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
bugout "github.com/bugout-dev/bugout-go/pkg"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
|
@ -21,11 +23,15 @@ var (
|
|||
|
||||
supportedBlockchains map[string]bool
|
||||
|
||||
// Bugout client
|
||||
BUGOUT_BROOD_URL = os.Getenv("BUGOUT_BROOD_URL")
|
||||
NB_BUGOUT_TIMEOUT_SECONDS_RAW = os.Getenv("NB_BUGOUT_TIMEOUT_SECONDS")
|
||||
|
||||
// Bugout and application configuration
|
||||
BUGOUT_AUTH_CALL_TIMEOUT = time.Second * 5
|
||||
MOONSTREAM_APPLICATION_ID = os.Getenv("MOONSTREAM_APPLICATION_ID")
|
||||
NB_CONTROLLER_TOKEN = os.Getenv("NB_CONTROLLER_TOKEN")
|
||||
NB_CONTROLLER_ACCESS_ID = os.Getenv("NB_CONTROLLER_ACCESS_ID")
|
||||
BUGOUT_AUTH_CALL_TIMEOUT = time.Second * 5
|
||||
MOONSTREAM_APPLICATION_ID = os.Getenv("MOONSTREAM_APPLICATION_ID")
|
||||
NB_CONTROLLER_TOKEN = os.Getenv("NB_CONTROLLER_TOKEN")
|
||||
NB_CONTROLLER_ACCESS_ID = os.Getenv("NB_CONTROLLER_ACCESS_ID")
|
||||
|
||||
NB_CONNECTION_RETRIES = 2
|
||||
NB_CONNECTION_RETRIES_INTERVAL = time.Millisecond * 10
|
||||
|
@ -54,6 +60,18 @@ var (
|
|||
DEFAULT_AUTOGENERATED_MAX_CALLS_PER_PERIOD = int64(1000)
|
||||
)
|
||||
|
||||
func CreateBugoutClient() bugout.BugoutClient {
|
||||
bugoutTimeoutSeconds, err := strconv.Atoi(NB_BUGOUT_TIMEOUT_SECONDS_RAW)
|
||||
if err != nil {
|
||||
log.Printf("Unable to parse environment variable as integer: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
NB_BUGOUT_TIMEOUT_SECONDS := time.Duration(bugoutTimeoutSeconds) * time.Second
|
||||
|
||||
broodClient := bugout.ClientBrood(BUGOUT_BROOD_URL, NB_BUGOUT_TIMEOUT_SECONDS)
|
||||
return broodClient
|
||||
}
|
||||
|
||||
func CheckEnvVarSet() {
|
||||
if NB_ACCESS_ID_HEADER == "" {
|
||||
NB_ACCESS_ID_HEADER = "x-node-balancer-access-id"
|
||||
|
|
|
@ -3,7 +3,7 @@ module github.com/bugout-dev/moonstream/nodes/node_balancer
|
|||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/bugout-dev/bugout-go v0.4.2
|
||||
github.com/bugout-dev/bugout-go v0.4.3
|
||||
github.com/bugout-dev/humbug/go v0.0.0-20211206230955-57607cd2d205
|
||||
github.com/google/uuid v1.3.0
|
||||
)
|
||||
|
|
|
@ -23,8 +23,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
|
|||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
|
||||
github.com/bugout-dev/bugout-go v0.4.2 h1:oADFQzZ4iZeQOz8dDaO/+25eQkrCYG8SqjA8mRSQl7k=
|
||||
github.com/bugout-dev/bugout-go v0.4.2/go.mod h1:P4+788iHtt/32u2wIaRTaiXTWpvSVBYxZ01qQ8N7eB8=
|
||||
github.com/bugout-dev/bugout-go v0.4.3 h1:sTwMgNDZR8mK0BkPVfXIsFWZAkL8ePKr5Xmj35A2O3o=
|
||||
github.com/bugout-dev/bugout-go v0.4.3/go.mod h1:P4+788iHtt/32u2wIaRTaiXTWpvSVBYxZ01qQ8N7eB8=
|
||||
github.com/bugout-dev/humbug/go v0.0.0-20211206230955-57607cd2d205 h1:UQ7XGjvoOVKGRIuTFXgqGtU/UgMOk8+ikpoHWrWefjQ=
|
||||
github.com/bugout-dev/humbug/go v0.0.0-20211206230955-57607cd2d205/go.mod h1:U/NXHfc3tzGeQz+xVfpifXdPZi7p6VV8xdP/4ZKeWJU=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# Required environment variables for load balancer
|
||||
export BUGOUT_BROOD_URL="https://auth.bugout.dev"
|
||||
export NB_BUGOUT_TIMEOUT_SECONDS=15
|
||||
export MOONSTREAM_APPLICATION_ID="<application_id_to_controll_access>"
|
||||
export NB_CONTROLLER_TOKEN="<token_of_controller_user>"
|
||||
export NB_CONTROLLER_ACCESS_ID="<controller_access_id_for_internal_usage>"
|
||||
|
|
Ładowanie…
Reference in New Issue