options.go 888 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package nsqlookupd
  2. import (
  3. "log"
  4. "os"
  5. "time"
  6. "github.com/nsqio/nsq/internal/lg"
  7. )
  8. type Options struct {
  9. LogLevel lg.LogLevel `flag:"log-level"`
  10. LogPrefix string `flag:"log-prefix"`
  11. Logger Logger
  12. TCPAddress string `flag:"tcp-address"`
  13. HTTPAddress string `flag:"http-address"`
  14. BroadcastAddress string `flag:"broadcast-address"`
  15. InactiveProducerTimeout time.Duration `flag:"inactive-producer-timeout"`
  16. TombstoneLifetime time.Duration `flag:"tombstone-lifetime"`
  17. }
  18. func NewOptions() *Options {
  19. hostname, err := os.Hostname()
  20. if err != nil {
  21. log.Fatal(err)
  22. }
  23. return &Options{
  24. LogPrefix: "[smqlookupd] ",
  25. LogLevel: lg.INFO,
  26. TCPAddress: "0.0.0.0:9060",
  27. HTTPAddress: "0.0.0.0:9061",
  28. BroadcastAddress: hostname,
  29. InactiveProducerTimeout: 300 * time.Second,
  30. TombstoneLifetime: 45 * time.Second,
  31. }
  32. }