Skip to content

Commit

Permalink
chore: Set default values for flag vars
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Nov 13, 2024
1 parent 05cef89 commit e13e71a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
6 changes: 1 addition & 5 deletions internal/movie/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ const SpeedFlag = "speed"
var ErrInvalidSpeed = errors.New("speed must be greater than 0")

func Flags(flags *flag.FlagSet) {
flags.Float64(
SpeedFlag,
1,
"Playback speed multiplier. Must be greater than 0.",
)
flags.Float64(SpeedFlag, 1, "Playback speed multiplier. Must be greater than 0.")
}

func FromFlags(flags *flag.FlagSet, path string) (Movie, error) {
Expand Down
12 changes: 6 additions & 6 deletions internal/server/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const (

//nolint:gochecknoglobals
var (
concurrentStreams uint
idleTimeout time.Duration
maxTimeout time.Duration
concurrentStreams = uint(10)
idleTimeout = 15 * time.Minute
maxTimeout = 2 * time.Hour
)

func Flags(flags *flag.FlagSet) {
Expand All @@ -42,9 +42,9 @@ func Flags(flags *flag.FlagSet) {
flags.Bool(APIFlagPrefix+EnabledFlag, true, "Enables API listener")
flags.String(APIFlagPrefix+AddressFlag, "127.0.0.1:1977", "API listen address")

flags.UintVar(&concurrentStreams, ConcurrentStreamsFlag, 10, "Number of concurrent streams allowed from an IP address. Set to 0 to disable.")
flags.DurationVar(&idleTimeout, IdleTimeoutFlag, 15*time.Minute, "Idle connection timeout.")
flags.DurationVar(&maxTimeout, MaxTimeoutFlag, 2*time.Hour, "Absolute connection timeout.")
flags.UintVar(&concurrentStreams, ConcurrentStreamsFlag, concurrentStreams, "Number of concurrent streams allowed from an IP address. Set to 0 to disable.")
flags.DurationVar(&idleTimeout, IdleTimeoutFlag, idleTimeout, "Idle connection timeout.")
flags.DurationVar(&maxTimeout, MaxTimeoutFlag, maxTimeout, "Absolute connection timeout.")

flags.Duration(TimeoutFlag, time.Hour, "Maximum amount of time that a connection may stay active.")
must.Must(flags.MarkDeprecated(TimeoutFlag, "please use --idle-timeout and --max-timeout instead."))
Expand Down

0 comments on commit e13e71a

Please sign in to comment.