-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
39 lines (32 loc) · 1.1 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
package main
import (
"context"
"flag"
"fmt"
"os"
"github.com/holoplot/nats-bench/client"
"github.com/holoplot/nats-bench/consumer"
)
func main() {
approach := flag.String("approach", "multiple-filter-subjects", fmt.Sprintf("One of %v", consumer.Approaches()))
numRealms := flag.Int("num-realms", 10000, "Number of items in the config realm")
numConsumers := flag.Int("num-consumers", 10, "Number of consumers")
numRealmsPerConsumer := flag.Int("num-realms-per-consumer", 10, "Number of subjects each consumer subscribes to")
flag.Parse()
config := client.Config{
Approach: consumer.NewApproach(*approach),
NumRealms: *numRealms,
NumConsumers: *numConsumers,
NumRealmsPerConsumer: *numRealmsPerConsumer,
Suffixes: []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"},
}
if natsURL, ok := os.LookupEnv("NATS_URL"); ok {
config.NatsURL = natsURL
} else {
config.NatsURL = "localhost:4222"
}
client := client.New(config)
result := client.Run(context.Background())
fmt.Printf("%s\n", config.String())
fmt.Printf("%s\n", result.String())
}