-
Notifications
You must be signed in to change notification settings - Fork 12
Refactor state management outside the overlord. #18
Conversation
This will ease future usage of a central DB for state between an array of overlords.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
src/go/overlord/statemanager.go
Outdated
} | ||
|
||
// LocalStateManager handles state through a local time-expiring cache. | ||
type LocalStateManager struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could move this to a separate package (say, 'state'), and name this Local. Then calling this would be state.NewLocal(), and in future also state.NewFoobar where Foobar is some form of a distributed state manager.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good idea. One drawback though is that mappedInterest is now caught between the 2 packages (it's defined in the overlord, I was using it in state). Any suggestions on how to break this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've moved everything into the state package :-) Let me know what you think
Move state interface where it's used. [Note this does not compile yet, followup CL on interests comng up]
Move mappedInterest to the state package as an exported struct.
This will ease future usage of a central DB for state between an array of overlords.
It uses a local cache through the same library and general set up we have in the Minion, making it a bit easier to test parts of the Overlord.
Note that in this refactoring I pulled out the chunk-merging code away from the overlord and into the implementation of the state manager, which might - or quite likely might not - be the right thing to do.