A template influenced Clean Architecture featuring in EDA (Event Driven Architecture) systems. Featuring patterns:
- FanIn FanOut
- Worker Pool
Install virtual env (assume python installed, skip if already installed)
python -m venv venvActivate virtual env (for Windows)
./venv/bin/ActivateInstall pre-commit (skip if already installed)
pip install pre-commit
pre-commit installChange config.yaml to an appropriate configuration.
Change consumer-blueprint to a specific name
Install dependency
go mod tidyRun without docker (assumed you have Makefile command installed):
make runmake unittestEach goroutine will be spawned on demand which means goroutine spawned as soon as a message came. Only number of goroutines are spawned as much as a specified one in config file. Be careful with a massive high workers will cause the program crashed. Depending on topics of messages came, the manager will route to an appropriate handler.
Add more use cases (handlers) in the usecase folder. Each use case represents a topic the use case is responsible for
and must implement Consumer interface with a well-defined model which defined the message format of a topic.
You can learn it by finding an example in the template. You must register a topic for that particular use case
in main.go ( right after you finished writing logics for an use case ). For example:
registra.RegisterTopic(cfg.Kafka.Topic, kafka.NewJsonConsumer(h1))But don't forget to initialize that use case before registering handler.
h1 := usecase.NewUseCase(a.Logger)- Consumer of Dead Letter Queue Topic