Open
Description
At the moment, we run 3 queues
save chan ItemRequest
fetch chan Request
delete chan Request
func (s *KVStore) loop() {
for {
select {
case setRequest := <-s.save:
// set process
case getRequest := <-s.fetch:
// get process
case delRequest := <-s.delete:
// del process
}
}
}
This leads to a situation where save
has bigger priority than fetch
and might behave unexpectedly in corner case scenarios.
In order to further strengthen thread safety, it would be good to run a select
loop on a single channel like a work unit.
func (s *KVStore) loop() {
for {
select {
case request := <-s.operations:
// unified process
}
}
}
Shape of the Request
in operations chan Request
is yet to be decided as mistakes here might lead to type safety issues. Obviously we dont want to trade thread safety for type safety.
Issue open for thoughts
Metadata
Assignees
Labels
No labels
Activity