Skip to content

v0.11.0

Pre-release
Pre-release
Compare
Choose a tag to compare
@tmaxmax tmaxmax released this 13 May 23:06
v0.11.0
e3ddbdf

The sse.Server logging and session handling were revamped to have more familiar, more flexible and less error prone interfaces for users. Some bugs were also fixed.

Removed

  • Logger and LogLevel enum have been removed. Server.Logger has transitioned to the standard slog library for better compatibility with the ecosystem

Changed

  • Server.Logger is now of type func(r *http.Request) *slog.Logger instead of sse.Logger – it is possible to customize the logger on a per-request basis, by for example retrieving it from the context.
  • Server.OnSession signature changed from func(s *Session) (Subscription, bool) to func(w http.ResponseWriter, r *http.Request) (topics []string, accepted bool) – its initial role was to essentially just provide the topics, so the need to fiddle with Session and Subscription was redundant anyway
  • Joe.Subscribe now always returns ErrProviderClosed when a Joe instance is closed while subscriptions are active. Previously it would return it only if Joe was already shut down before subscribing.
  • Joe will print a stack trace for Replayer panics.

Fixed

  • sse.Session doesn't write the header explicitly anymore. This would cause a http: superfluous response.WriteHeader call warning being logged when sse.Server.OnSession writes a response code itself when accepting a session. The change was initially introduced to remove the warning for users of certain external libraries (see #41) but this is the issue of the external library, not of go-sse. If you encounter this warning when using an external library, write the response code yourself in the HTTP handler before subscribing the sse.Session, as described in the linked discussion.
  • An insidious synchronization issue in Joe causing a channel double close in an edge case scenario (see #50, see code for details)

New Contributors