Skip to content

Commit

Permalink
streamer: add more info prints on why the streamer decides to do things
Browse files Browse the repository at this point in the history
  • Loading branch information
Wessie committed May 18, 2024
1 parent 978ec6f commit 508290b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions streamer/streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,36 @@ func NewStreamer(ctx context.Context, cfg config.Config, qs radio.QueueService,
return nil, errors.E(op, err)
}
s.StreamUser = *user

zerolog.Ctx(ctx).Info().Str("username", user.Username).Msg("this is me")
return s, nil
}

func (s *Streamer) userChange(ctx context.Context, user *radio.User) {
// nobody is streaming
if user == nil {
zerolog.Ctx(ctx).Info().Msg("nobody streaming")

// we are allowed to connect after a timeout if one is set
if timeout := s.Conf().Streamer.ConnectTimeout; timeout > 0 {
zerolog.Ctx(ctx).Info().
Dur("timeout", time.Duration(timeout)).
Msg("starting after timeout")
s.startTimer.Start(time.Duration(timeout))
return
}
}
// if we are supposed to be streaming, we can connect
if user.ID == s.StreamUser.ID {
zerolog.Ctx(ctx).Info().Msg("starting because (me)")
s.Start(context.WithoutCancel(ctx))
return
}

zerolog.Ctx(ctx).Info().
Str("me", s.StreamUser.Username).
Str("user", user.Username).
Msg("not starting")
}

// Start starts the streamer with the context given, Start is a noop if
Expand Down
2 changes: 1 addition & 1 deletion util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ func StreamValue[T any](ctx context.Context, fn StreamFn[T], callbackFn ...Strea
// retrying, or that was our original error and we exit
return
case <-time.After(time.Second):
continue
}
continue
}

for {
Expand Down

0 comments on commit 508290b

Please sign in to comment.