This is an example of a "model" microservice using @servicebus/rabbitbus
, because model services are the most complex, and most necessary :)
It uses Event Sourcing with sourced
.
This model service doesn't need an HTTP API, to see an example of using servicebus with an API, check out: https://github.com/patrickleet/servicebus-api-template
./bin/start.mjs
- Starts the application:
- Connects to DB
- Configures a bus
- Registers command/event handlers with
servicebus-register-handlers
- If you find the "common" settings don't work for you, it's easy to use your own!
./handlers/*
- Event and command handlers
- Events are "published" with
bus.publish
, and services cansubscribe
to those events - Commands are "sent" with
bus.send
, and services canlisten
for those commands
- Events are "published" with
- Imported/Required by
servicebus-register-handlers
when the service starts
./config.mjs
- Using
cconfig
for configuration- A "cascading configuration" tool
- env variables are applied on top of default config
- can configure environment specific configs as well
That's it! The rest is tooling.
helm install --namespace servicebus stable/rabbitmq
helm install --namespace servicebus stable/redis
helm install --namespace todolist --name sourced-db stable/mongodb\
--set mongodbRootPassword=asecretpassword,mongodbUsername=username,mongodbPassword=apassword,mongodbDatabase=sourced \
stable/mongodb