Skip to content
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

History container #56

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

History container #56

wants to merge 2 commits into from

Conversation

kbrock
Copy link
Contributor

@kbrock kbrock commented Mar 29, 2013

This history stores notification that have been sent.

This does not know much about the objects stored.

But it does know:

  • old records are of no interest
  • after records are searched, throw everything away
  • in the scan, the match, and all of the ones closer to the head of the stack are of interest
  • scan for records from the head (like a stack not a queue)

As we work through this, knowledge of the response code and notification may make things better

@kbrock
Copy link
Contributor Author

kbrock commented Mar 29, 2013

Thanks @stevenharman for pointing out https://github.com/vanstee/grocer/blob/2fd146d4816795ad79f4e2c5beb5a101d00dc72e/lib/grocer/history.rb

  • All of the ring buffer implementations that I see out there have a concept of full / out of space.
  • They also assume a queue instead of a stack.
  • As a nitpick, they also seem to want array size == capacity. Introducing the case where if the front == the back, you need to decide is it full or empty. allowing the array size to be capacity + 1 allows simpler code.

@vanstee 's implementation (link above) is so clean.
I worry about the base case. adding an alert to a full list. Wanted to avoid allocating a bunch of space for that use case. So this implementation looks more like C than ruby. Haven't profiled it, so it could be worse for all I know.

@kbrock
Copy link
Contributor Author

kbrock commented Mar 29, 2013

Not knowing about error responses and notifications really simplifies the tests and keeps it simple.
But there are a few things that would be nice if it knew about other objects in the system.

Thinking about introducing:

  1. know about notifications and auto assign an identifier - probably keep it from 1..(@SiZe*10)
  2. ability to scan from the back for notifications that were sent a while ago (notification could get sent_at field)
  3. know about error responses. find_culpret could assign the notification into the error response, maybe even assign the notifications that were resent as a result.

@kbrock
Copy link
Contributor Author

kbrock commented Mar 29, 2013

I created a history with knowledge of the framework at https://github.com/kbrock/grocer/blob/knowledgeable_history/lib/grocer/history.rb

I think it makes for a nice pusher api, but not sure if so much knowledge should be embedded in a collection class.

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.

None yet

1 participant