Package: robotnikmq
RobotnikMQUtilities for safe, efficient, and scalable infrastructure using RabbitMQUsageTODOInstallation & SetupTo install robotnikmq withpipexecute the following:pipinstallrobotnikmqConfigurationRobotnikMQ can be configured globally, on a per-user, or on a per-application basis. When certain functions of the RobotnikMQ library are called without a provided configuration, it will attempt to find a configuration first for the application in the current working directory./robotnikmq.yaml, then for the user in~/.config/robotnikmq/robotnikmq.yamland then for the system in/etc/robotnikmq/robotnikmq.yaml. An error will be raised if a configuration is not provided and neither of those files exist.The RobotnikMQ configuration is primarily a list of servers organized into tiers. If a given system or user can be expected to connect to the same cluster the vast majority of the time, then you can/should use a per-user or global configuration. Otherwise, simply have your application configure its own RobotnikMQ configuration (seeUsagesection).The configuration file itself should look something like this:tiers:--ca_cert:/home/eugene/Development/robotnikmq/tests/integration/vagrant/pki/robotnik-ca.crtcert:/home/eugene/Development/robotnikmq/tests/integration/vagrant/pki/issued/rabbitmq-vm/rabbitmq-vm.crthost:127.0.0.1key:/home/eugene/Development/robotnikmq/tests/integration/vagrant/pki/issued/rabbitmq-vm/rabbitmq-vm.keypassword:''port:1user:''vhost:''-ca_cert:/home/eugene/Development/robotnikmq/tests/integration/vagrant/pki/robotnik-ca.crtcert:/home/eugene/Development/robotnikmq/tests/integration/vagrant/pki/issued/rabbitmq-vm/rabbitmq-vm.crthost:'1'key:/home/eugene/Development/robotnikmq/tests/integration/vagrant/pki/issued/rabbitmq-vm/rabbitmq-vm.keypassword:'1'port:1user:'1'vhost:'1'--ca_cert:/home/eugene/Development/robotnikmq/tests/integration/vagrant/pki/robotnik-ca.crtcert:/home/eugene/Development/robotnikmq/tests/integration/vagrant/pki/issued/rabbitmq-vm/rabbitmq-vm.crthost:127.0.0.1key:/home/eugene/Development/robotnikmq/tests/integration/vagrant/pki/issued/rabbitmq-vm/rabbitmq-vm.keypassword:hackmeport:5671user:robotnikvhost:/robotnikIn the example above, you should be able to see two tiers of servers, the first has two server configurations that are intentionally broken for testing purposes, while the second has a valid configuration (this is the configuration that is used for unit-testing).The idea is that RobotnikMQ will first attempt to connect to all servers in the first tier in a random order, then if all of them fail, it will attempt to connect to all the servers in the second tier, and so on. This is intended to allow both load-balancing on different servers and for redundancy in case some of those servers fail. You can also configure only one tier with one server, or just a list of tiers, each of which have one server in them. This way, the secondary and tertiary servers would only be used if there is something wrong with the primary.DevelopmentStandardsBe excellent to each otherCode coverage must be at 100% for all new code, or a good reason must be provided for why a given bit of code is not covered.Example of an acceptable reason: "There is a bug in the code coverage tool and it says its missing this, but its not".Example of unacceptable reason: "This is just exception handling, its too annoying to cover it".The code must pass the following analytics tools. Similar exceptions are allowable as in rule 2.pylint --disable=C0103,C0111,W1203,R0903,R0913 --max-line-length=120 ...flake8 --max-line-length=120 ...mypy --ignore-missing-imports --follow-imports=skip --strict-optional ...All incoming information from users, clients, and configurations should be validated.All internal arguments passing should be typechecked during testing withtypeguard.typecheckedorthe import hook.Development SetupUsingpdminstall from inside the repo directory:pdminstallThis will install all dependencies (including dev requirements) in aPEP582-compliant projectwhich you can always run specific commands withpdm run ....IDE SetupSublime Text 3curl-sSLhttps://gitlab.com/-/snippets/2385805/raw/main/pdm.sublime-project.py|pdmrunpython>robotnikmq.sublime-projectVSCodium/VSCodeI recommend installing thepdm-vscodeplug-in:sudopdmpluginaddpdm-vscodeTestingAll testing should be done withpytestwhich is installed with thedevrequirements.To run all the unit tests, execute the following from the repo directory:pdmrunpytestThis should produce a coverage report in/path/to/dewey-api/htmlcov/While developing, you can usewatchexecto monitor the file system for changes and re-run the tests:watchexec-r-epy,yamlpdmrunpytestTo run a specific test file:pdmrunpytesttests/unit/test_core.pyTo run a specific test:pdmrunpytesttests/unit/test_core.py::test_helloFor more information on testing, see thepytest.inifile as well as thedocumentation.Integration TestingFor integration testing, this code usestestcontainers-rabbitmq. In order to enable this, you will need to install docker, and ensure that your user has the ability to interact with the docker service:sudoaptinstalldocker
sudogroupadddocker# may fail if the docker group already existssudousermod-aGdocker$USERnewgrpdocker
dockerrunhello-world# verify that everything is working well