I try design a dispatcher using go in a concurrency situation, the dispatcher needs to dispatch the message to its dedicated worker which only treat one kind of messages (or workers), ex:
As I can add/remove dynamically the dedicated worker treating different types of messages. Now I need a message pattern to do so with only goroutine and channel. I plan to have a channel -- a pool of same type workers, and put the channels in a map, so I can distribute message by type according to the keys in map, if the worker for treating message C is not exist, it will just dispatch the message to garbage channel for non-treating, and the same type of workers can process the same type of messages concurrently. I am not sure if it is a better design or not, any suggestion?
Thank you in advance.