Actions
Story #3705
closed[Keep] Generalize PullList module to BlockWorkList
Start date:
08/21/2014
Due date:
% Done:
100%
Estimated time:
(Total: 0.00 h)
Story points:
2.0
Description
The lists of "blocks to delete" and "blocks to pull from other keepstores" should be maintained in a BlockWorkList type. Just like the existing PullList, a BlockWorkList has
- a current list
- a dedicated goroutine responsible for setting and getting the current list
- a block hash
- some additional data (sending/accepting the right type here is left up to the callers)
NewBlockWorkList()
- Returns a new BlockWorkList. Starts a new goroutine.
ReplaceList
- Writing a list to this channel replaces the current list, if any, with the supplied list. (The remainder of the old list is discarded. Any work still in progress on old list items is unaffected.)
NextItem
- Reading from this channel yields the next item from the list. (The returned item is also removed from the list.)
Close()
- Terminates the goroutine, closes the channels.
Pseudocode for a trash collector:
// Make a work list: trashList := NewBlockWorkList() // In an HTTP handler for "PUT /trash": { trashList.SetList(...) } // Start a worker: go func(list BlockWorkList) { for deleteRequest := range list.NextItem { // Check timestamp and delete the block. } }(trashList)
Actions