-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (33 loc) · 1.05 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"flag"
"fmt"
"log/slog"
"github.com/BKadirkhodjaev/request-cli/orders"
)
const CommandName string = "main"
var (
environment string
threadCount int
enableDebug bool
)
func main() {
parseArgs()
gatewayHostname := getGatewayHostname(environment)
orders.ParseCsvAndOpenOrdersInBulk(gatewayHostname, enableDebug, threadCount)
}
func parseArgs() {
flag.StringVar(&environment, "env", "okapi", "Environment to run on (okapi or eureka)")
flag.IntVar(&threadCount, "threads", 50, "Persistent HTTP thread count")
flag.BoolVar(&enableDebug, "debug", false, "Enable debug output of HTTP request and response")
flag.Parse()
slog.Info(CommandName, "Using arguments", fmt.Sprintf("Environment: %s", environment))
slog.Info(CommandName, "Using arguments", fmt.Sprintf("Enable debug: %t", enableDebug))
slog.Info(CommandName, "Using arguments", fmt.Sprintf("Thread count: %d", threadCount))
}
func getGatewayHostname(environment string) string {
if environment == "okapi" {
return "http://localhost:9130"
}
return "http://localhost:8000"
}