Been a happy user of this library for a couple of years and it works great! :smiley:
Something I've wanted and needed for a while is the ability to set a limit on the amount of events the event log can store, and being able to set if it should replay per stream and not globally.
This PR implements a new log store using container/list of the std library.
Along with that it adds the new method CreateStreamWithOpts(id string, opts StreamOpts) which takes a StreamOpts config:
type StreamOpts struct {
// Max amount of log entries per stream
MaxEntries int
// Enables creation of a stream when a client connects
AutoStream bool
// Enables automatic replay for each new subscriber that connects
AutoReplay bool
}
The benefits of a new method is the backwards compatibility is kept.
When MaxEntries is set to a value greater than 0 it will check the length on Add, then remove the log at the back, and insert the new log event.
Added a new test case for the limit and all other passes
Updated Go mod version and ran go mod tidy as well as updated golang.org/x/net which was vulnerable
Happy to take any feedback! And please let me know if this is something of interest at all. If not then I'll maintain a fork. :smile:
If you think container/list is a bad idea, then we could possibly expose a LogStorer interface and have that configurable by the user and keep the old implementation as default.
Hi!
Been a happy user of this library for a couple of years and it works great! :smiley:
Something I've wanted and needed for a while is the ability to set a limit on the amount of events the event log can store, and being able to set if it should replay per stream and not globally.
This PR implements a new log store using container/list of the std library.
Along with that it adds the new method
CreateStreamWithOpts(id string, opts StreamOpts)
which takes aStreamOpts
config:The benefits of a new method is the backwards compatibility is kept.
When
MaxEntries
is set to a value greater than 0 it will check the length onAdd
, then remove the log at the back, and insert the new log event.go mod tidy
as well as updatedgolang.org/x/net
which was vulnerableHappy to take any feedback! And please let me know if this is something of interest at all. If not then I'll maintain a fork. :smile:
If you think
container/list
is a bad idea, then we could possibly expose aLogStorer
interface and have that configurable by the user and keep the old implementation as default.