Skip to content

Aggregate operations into a single work request #2

Open
@spekulant

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions