Skip to content

Commit 503f410

Browse files
committed
add minimalist golang tool to allow for waku simulation compose generation
1 parent 759533a commit 503f410

File tree

13 files changed

+1347
-3
lines changed

13 files changed

+1347
-3
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
BIN_DIR = bin/
2+
CLI = bin/wakusim
3+
4+
build:
5+
go build -o $(CLI) main.go
6+
7+
clean:
8+
rm -rf $(CLI)

cmd/wakusim/generate.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package wakusim
2+
3+
import (
4+
"fmt"
5+
"log"
6+
7+
"github.com/spf13/cobra"
8+
"github.com/waku-org/waku-simulator/internal/simulate"
9+
)
10+
11+
var generateCmd = &cobra.Command{
12+
Use: "gen",
13+
Run: func(cmd *cobra.Command, args []string) {
14+
simulation, err := cmd.Flags().GetString("simulation")
15+
if err != nil {
16+
log.Fatal(err)
17+
}
18+
19+
s := simulate.NewSimulation(simulation, "")
20+
21+
err = s.Load(fmt.Sprintf("%s.yaml", simulation))
22+
if err != nil {
23+
log.Fatal(err)
24+
}
25+
26+
err = s.Generate()
27+
if err != nil {
28+
log.Fatal(err)
29+
}
30+
},
31+
}
32+
33+
func init() {
34+
rootCmd.AddCommand(generateCmd)
35+
}

cmd/wakusim/root.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package wakusim
2+
3+
import (
4+
"log"
5+
6+
"github.com/spf13/cobra"
7+
)
8+
9+
var version = "v0.0.0"
10+
11+
var rootCmd = &cobra.Command{
12+
Use: "waksim",
13+
Version: version,
14+
}
15+
16+
func Execute() {
17+
var err error
18+
19+
err = rootCmd.Execute()
20+
if err != nil {
21+
log.Fatalln(err)
22+
}
23+
}
24+
25+
func init() {
26+
rootCmd.PersistentFlags().StringP("simulation", "s", "default", "name of the simulation")
27+
}

default.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Basic simulation
2+
bootstrap: true
3+
publisher:
4+
image: alrevuelta/waku-publisher:9fb206c
5+
msq_per_sec: 10
6+
msg_size_kb: 10
7+
groups:
8+
- name: nwaku
9+
type: nwaku
10+
image: statusteam/nim-waku:v0.19.0
11+
count: 2
12+
args:
13+
- --relay
14+
env:
15+
POSTGRES_USER: nwaku
16+
POSTGRES_PASSWORD: verysecret
17+
volumes:
18+
- src: ./data
19+
dst: /data
20+
per_node: true
21+
- name: nwaku-extra
22+
type: nwaku
23+
image: statusteam/nim-waku:v0.19.0
24+
count: 2
25+
args:
26+
- --filter=true
27+
- --store=true
28+
env:
29+
POSTGRES_USER: nwaku
30+
POSTGRES_PASSWORD: verysecret
31+
volumes:
32+
- src: ./data
33+
dst: /data
34+
per_node: true
35+
- name: gowaku
36+
type: gowaku
37+
image: statusteam/go-waku:latest
38+
count: 2
39+
args:
40+
- --relay
41+
volumes:
42+
- src: /home/vpavlin/devel/github.com/vpavlin/waku-simulator/go-data
43+
dst: /data

go.mod

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
module github.com/waku-org/waku-simulator
2+
3+
go 1.18
4+
5+
require github.com/spf13/cobra v1.7.0
6+
7+
require (
8+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0 // indirect
9+
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 // indirect
10+
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
11+
github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect
12+
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
13+
github.com/aws/aws-sdk-go v1.44.302 // indirect
14+
github.com/beorn7/perks v1.0.1 // indirect
15+
github.com/cespare/xxhash/v2 v2.2.0 // indirect
16+
github.com/distribution/distribution/v3 v3.0.0-20230214150026-36d8c594d7aa // indirect
17+
github.com/docker/go-connections v0.4.0 // indirect
18+
github.com/go-kit/log v0.2.1 // indirect
19+
github.com/go-logfmt/logfmt v0.6.0 // indirect
20+
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
21+
github.com/golang/protobuf v1.5.3 // indirect
22+
github.com/google/uuid v1.3.0 // indirect
23+
github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd // indirect
24+
github.com/jmespath/go-jmespath v0.4.0 // indirect
25+
github.com/jpillora/backoff v1.0.0 // indirect
26+
github.com/kylelemons/godebug v1.1.0 // indirect
27+
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
28+
github.com/mitchellh/mapstructure v1.5.0 // indirect
29+
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
30+
github.com/opencontainers/go-digest v1.0.0 // indirect
31+
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
32+
github.com/pkg/errors v0.9.1 // indirect
33+
github.com/prometheus/client_golang v1.16.0 // indirect
34+
github.com/prometheus/client_model v0.4.0 // indirect
35+
github.com/prometheus/common v0.44.0 // indirect
36+
github.com/prometheus/common/sigv4 v0.1.0 // indirect
37+
github.com/prometheus/procfs v0.11.0 // indirect
38+
github.com/sirupsen/logrus v1.9.0 // indirect
39+
golang.org/x/crypto v0.11.0 // indirect
40+
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect
41+
golang.org/x/net v0.12.0 // indirect
42+
golang.org/x/oauth2 v0.10.0 // indirect
43+
golang.org/x/sync v0.3.0 // indirect
44+
golang.org/x/sys v0.10.0 // indirect
45+
golang.org/x/text v0.11.0 // indirect
46+
google.golang.org/appengine v1.6.7 // indirect
47+
google.golang.org/protobuf v1.31.0 // indirect
48+
gopkg.in/yaml.v2 v2.4.0 // indirect
49+
)
50+
51+
require (
52+
github.com/compose-spec/compose-go v1.18.1
53+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
54+
github.com/otiai10/copy v1.12.0
55+
github.com/prometheus/prometheus v0.46.0
56+
github.com/spf13/pflag v1.0.5 // indirect
57+
gopkg.in/yaml.v3 v3.0.1
58+
)

0 commit comments

Comments
 (0)