This is part of nanoservice core.
Listens to specific topic on Bus and fans out messages to clients in round-robin fashion.
Enables canary deployment.
It uses Apache Kafka as a Bus.
- subscribe to one topic
- subscribe to test topic
- subscribe to all partitions of this topic
- subscribe to topic provided by commandline argument
- listen to multiple kafkas (up to 3)
- detect count of available kafkas and listen to all of them
- fanout to the clients
- fanout everything to all clients
- balance messages for clients
- send message to other client if there is no ack
- buffer consumed messages if there are no clients and try to re-send as soon a there are
- detect closed connections properly (send heartbeats to the clients and expect an ack back)
- stop consuming the topic if there are no clients
- maintain the offset per each partition in zookeeper
- start consuming from saved offset per each partition instead of newest
- connect to up to 3 zookeepers
- detect count of available zookeepers and connect to all of them
- durability
- add heartbeats on special topic
fanout_service_x_#{topic_name}
- vote on master when there are no heartbeats from current leader
- non-leaders return redirect-type response for clients pointing to leader
- add heartbeats on special topic
- performance
- setup benchmarks
- implement example nanoservices to use fanout
- adjust implementation to add minimal overhead possible
- consistency
- be at least "Eventually consistent":
- one event SHOULD be received by client at least once
- one event COULD be received by client more than once
- be at least "Eventually consistent":
- logging
- use standard logging library instead of fmt
-
-v
option for showing logs withseverity > INFO
- testing
- basic integration tests
- special case integration tests (like network partition, for example)
- refactoring + unit tests
# Run fanout daemon on topic `user_need` and link to one `kafka` instance
docker run -d --link kafka:kafka --link zookeeper:zk \
nanoservice/fanout --id service_x --topic user_need
# Run fanout daemon with `kafka` cluster
docker run -d --link kafka_1:kafka_1 --link kafka_2:kafka_2 --link kafka_3:kafka_3 \
--link zookeeper_1:zk_1 --link zookeeper_2:zk_2 --link zookeeper_3:zk_3 \
nanoservice/fanout --id service_x --topic user_need
To run fanout cluster, just start multiple fanout instances with the same --id service_x
.
Make sure that both user_need
and fanout_service_x_user_need
topics exist or topic auto-creation is enabled in kafka.
TODO
TODO
To setup integration tests:
- If you use docker-machine + virtualbox, run this:
ln -s .virtualbox .fanout
- If you docker directly, run this:
ln -s .docker .fanout
After that you can run bin/integration
to verify it works
bin/deps
to install all dependenciesbin/test
to run all unit testsbin/integration
to run all unit+integration testsbin/protobufs
to re-generate protobufsbin/compose
to rundocker-compose
commands with rightdocker-compose.yml
file
Use normal TDD development style.
To use faster integration tests:
bin/dev-build
to build a base image for fanout, first time and when adding new dependency;bin/integration fast
to run faster integration test.
- Fork it ( https://github.com/nanoservice/core-fanout/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- waterlink Oleksii Fedorov, creator, maintainer