udp input except no clean shutdown

This commit is contained in:
Bel LaPointe
2023-03-24 18:48:54 -06:00
parent 126f5ab60a
commit 287b9c7b4e
3 changed files with 54 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ package input
import (
"context"
"os"
"strconv"
"syscall"
)
@@ -47,6 +48,12 @@ func newSourceFunc() func() Input {
return singletonKeyboard
}
}
if port, _ := strconv.Atoi(os.Getenv("INPUT_UDP")); port != 0 {
singletonUDP := NewUDP(port)
return func() Input {
return singletonUDP
}
}
return func() Input {
generator := randomCharFromRange('a', 'g')
if p, ok := os.LookupEnv("INPUT_RANDOM_WEIGHT_FILE"); ok && len(p) > 0 {