Skip to content

v0.6.0

Pre-release
Pre-release
Compare
Choose a tag to compare
@tmaxmax tmaxmax released this 22 Jul 11:25
· 51 commits to master since this release
v0.6.0
4187103

This version brings a number of refactors to the server-side tooling the library offers. Constructors and construction related types are removed, for ease of use and reduced API size, concerns regarding topics and expiry were separated from Message, logging of the Server is upgraded to structured logging and messages can be now published to multiple topics at once. Request upgrading has also been refactored to provide a more functional API, and the Server logic can now be customized without having to create a distinct handler.

Removed

  • Message.ExpiresAt is no more.
  • Message.Topic is no more. See the changes to Server, Provider and ReplayProvider for handling topics – you can now publish a message to multiple topics at once.
  • Message.Writer is no more. The API was redundant – one can achieve the same using strings.Builder and Message.AppendData. See the MessageWriter example for more.
  • NewValidReplayProvider is no more.
  • NewFiniteReplayProvider is no more.
  • NewJoe is no more.
  • JoeConfig is no more.
  • Server.Subscribe is no more – it never made sense.
  • Server.Provider is no more.
  • NewServer, ServerOption and friends are no more.
  • The Logger interface and the capability of the Server to use types that implement Logger as logging systems is removed.
  • SubscriptionCallback is no more (see the change to the Subscription type in the "Changed" section).

Added

  • Because the ValidReplayProvider constructor was removed, the fields ValidReplayProvider.{TTL,AutoIDs} were added for configuration.
  • Because the FiniteReplayProvider constructor was removed, the fields FiniteReplayProvider.{Count,AutoIDs} were added for configuration.
  • Because the Joe constructor was removed, the fields Joe.{ReplayProvider,ReplayGCInterval} were added for configuration.
  • Because the Server constructor was removed, the field Server.Provider was added for configuration.
  • New MessageWriter interface; used by providers to send messages and implemented by Session (previously named Request).
  • New ResponseWriter interface, which is a http.ResponseWriter augmented with a Flush method.
  • ValidReplayProvider has a new field Now which allows providing a custom current time getter, like time.Now, to the provider. Enables deterministic testing of dependents on ValidReplayProvider.
  • New Server.OnSession field, which enables customization of Server's response and subscriptions.
  • New Server.Logger field, which enables structured logging with logger retrieved from the request and customizable config of logged information.

Changed

  • ReplayProvider.Put takes a simple *Message and returns a *Message, instead of changing the *Message to which the **Message parameter points.
    It also takes a slice of topics, given that the Message doesn't hold the topic itself anymore. If the Message cannot be put, the method must now panic – see documentation for info.
  • Because Message.ExpiresAt is removed, the ValidReplayProvider sets the expiry itself.
  • Server.Publish now takes a list of topics.
  • Provider.Publish now takes a non-empty slice of topics.
  • ReplayProvider.Put now takes a non-empty slice of topics.
  • Provider.Stop is now Provider.Shutdown and takes now a context.Context as a parameter.
  • Server.Shutdown takes now a context.Context as a parameter.
  • Request is now named Session and exposes the HTTP request, response writer, and the last event ID of the request.
  • A new method Flush is added to Session; messages are no longer flushed by default, which allows providers, replay providers to batch send messages.
  • Upgrade now takes an *http.Request as its second parameter.
  • Subscription now has a Client field of type MessageWriter instead of a Callback.
  • Given the Subscription change, Provider.Subscribe and ReplayProvider.Replay now report message sending errors.

If you have any suggestions, things are breaking, need some help or want to show appreciation, please and feel free to open an issue, say somthing in the Discussion of this release, or text me in private using the socials on my profile!