Skip to content

feature: implement max log entries and replay per stream #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

zze0s
Copy link

@zze0s zze0s commented May 20, 2023

Hi!

Been a happy user of this library for a couple of years and it works great! 😃

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. 😄

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.

@snowbows
Copy link

@purehyperbole - any chance to get this feature released?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants