I would like to implement the following:
- Multiple worker goroutines running, each executing some business logic.
- Different Http handlers distributes work to these workers.
- Input (via a channel) to each goroutine will be some data (State) which will have one Key in it.
- Multiple data with same key is also possible.
Our requirement is that processing for a specific Key has to be serialised. e.g. goroutine 1 is processing data related to Key:1234 then other goroutines should not process other data for the same key before goroutine 1 does its job.
Can anybody suggest best approach to do that?
map[Key]chan State. - Peter