v0.5.0
Pre-releaseThis version comes with a series of internal refactorings that improve code readability and performance. It also replaces usage of []byte
for event data with string
– SSE is a UTF-8 encoded text-based protocol, so raw bytes never made sense. This migration improves code safety (less unsafe
usage and less worry about ownership) and reduces the memory footprint of some objects.
Creating events on the server is also revised – fields that required getters and setters, apart from data
and comments, are now simple public fields on the sse.Message
struct.
Across the codebase, to refer to the value of the event
field the name "event type" is used, which is the nomenclature used in the SSE specification.
Documentation and examples were also fixed and improved.
Added
- New
sse.EventName
type, which holds valid values for theevent
field, together with constructors (sse.Name
andsse.NewName
).
Removed
sse.Message
:AppendText
was removed, as part of the migration from byte slices to strings. SSE is a UTF-8 encoded text-based protocol – raw bytes never made sense.
Changed
- Minimum supported Go version was bumped from 1.16 to 1.19. From now on, the latest two major Go versions will be supported.
sse.Message
:AppendData
takesstring
s instead of[]byte
.sse.Message
:Comment
is now namedAppendComment
, for consistency withAppendData
.sse.Message
: The message's expiration is not reset anymore byUnmarshalText
.sse.Message
:UnmarshalText
now unmarshals comments aswell.sse.Message
:WriteTo
(andMarshalText
andString
as a result) replaces all newline sequences in data with LF.sse.Message
: TheExpiry
getter andSetExpiresAt
,SetTTL
setters are replaced by the public fieldExpiresAt
.sse.Message
: Event ID getter and setter are replaced by the publicID
field.sse.Message
: Event type (previously namedName
) getter and setter are replaced by the publicType
field.sse.Message
: Theretry
field value is now a public field on the struct. As a byproduct,WriteTo
will now make 1 allocation when writing events with theretry
field set.sse.NewEventID
is nowsse.NewID
, andsse.MustEventID
issse.ID
.sse.Event
: TheData
field is now of typestring
, not[]byte
.sse.Event
: TheName
field is now namedType
.
Fixed
sse.Message
:Clone
now copies the topic of the message to the new value.sse.Message
: ID fields that contain NUL characters are now ignored, as required by the spec, inUnmarshalText
.
If you have any suggestions, things are breaking, need some help or want to show appreciation, please and feel free to open an issue or text me in private using the socials on my profile!