From 594bc39470456fdec79551278e72f490b0b086fc Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Thu, 2 Mar 2023 09:52:15 -0700 Subject: [PATCH] use $MAIN_INTERVAL_DURATION --- src/main.go | 10 +++++++++- testdata/INPUT_RANDOM_WEIGHT_FILE.yaml | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 testdata/INPUT_RANDOM_WEIGHT_FILE.yaml diff --git a/src/main.go b/src/main.go index 1e57ecd..99c2ca9 100644 --- a/src/main.go +++ b/src/main.go @@ -5,13 +5,21 @@ import ( "mayhem-party/src/device/input" "mayhem-party/src/device/output" "mayhem-party/src/device/output/key" + "os" "time" ) func Main(ctx context.Context) error { reader := input.New() writer := output.New() - c := time.NewTicker(time.Millisecond * 50) + interval := time.Millisecond * 50 + if intervalS, ok := os.LookupEnv("MAIN_INTERVAL_DURATION"); !ok { + } else if v, err := time.ParseDuration(intervalS); err != nil { + panic(err) + } else { + interval = v + } + c := time.NewTicker(interval) defer c.Stop() block := func() bool { diff --git a/testdata/INPUT_RANDOM_WEIGHT_FILE.yaml b/testdata/INPUT_RANDOM_WEIGHT_FILE.yaml new file mode 100644 index 0000000..382f256 --- /dev/null +++ b/testdata/INPUT_RANDOM_WEIGHT_FILE.yaml @@ -0,0 +1,4 @@ +w: 20 +a: 10 +s: 5 +d: 40