Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,6 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# vscode files
.vscode
21 changes: 21 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python
build:
os: ubuntu-22.04
tools:
python: "3.11"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Declare the python requirements to build docs
python:
install:
- requirements: docs/requirements.txt
34 changes: 32 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Rmqtools
========
Welcome to Rmqtools!
====================
Rmqtools provides enhanced features for RabbitMQ development in Python.

Introduction
Expand All @@ -21,6 +21,33 @@ applications.
for unique publish-subscribe relationships to be set up outside of the
periodic status message use case contained in the high-level wrappers.

Installation
------------

Prerequisites
~~~~~~~~~~~~~

* Pika (`version 1.3.0+ <https://pika.readthedocs.io/en/stable/#installing-pika>`_)
* RabbitMQ (`version 3.12.0+ <https://rabbitmq.com/download.html>`_)

Note: Pika should be automatically installed when installing Rmqtools

Rmqtools is not currently available for download with PyPI. Once it is
available, it can be installed via pip::

pip install rmqtools

To install the latest version before Rmqtools is available on PyPI, use the
latest_ release on GitHub and download ``rmqtools-<version>-py3-none-any.whl``.
Then install the wheel file with pip::

pip install rmqtools-<version>-py3-none-any.whl

The prerelease version is currently available on the PyPI test site. It can
be installed via pip::

pip install -i https://test.pypi.org/simple/ rmqtools

Documentation
-------------
Documentation coming soon.
Expand Down Expand Up @@ -115,3 +142,6 @@ Exposed Classes
handler, defaults to ``[]``; operates like ``*args``
- ``kwargs : dict`` - a dictionary of keyword arguments to pass to the
response handler, defaults to ``{}``; operates like ``**kwargs``

.. aliases below here
.. _latest: https://github.com/ASTHROS/rmqtools/releases/latest
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
40 changes: 40 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Configuration file for the Sphinx documentation builder.
import sys
sys.path.insert(0, '../')
# needs_sphinx = '1.0'

extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'sphinx.ext.intersphinx',
'sphinx.ext.napoleon',
]

intersphinx_mapping = {
'python': ('https://docs.python.org/3/',
'https://docs.python.org/3/objects.inv'),
'pika': ('https://pika.readthedocs.io/en/stable/',
'https://pika.readthedocs.io/en/stable/objects.inv'),
}

templates_path = ['_templates']

source_suffix = '.rst'
master_doc = 'index'

project = 'rmqtools'
copyright = '2026, Christian Thompson, Paul Horton'
author = 'Christian Thompson, Paul Horton'
release = '1.0.0'
version = '.'.join(release.split('.')[0:2])

exclude_patterns = ['_build']
add_function_parenthesis = True
add_module_names = True
show_authors = True
pygments_style = 'sphinx'
modindex_common_prefix = ['rmqtools']
html_theme = 'default'
html_static_path = ['_static']

# autoclass_content = 'both'
9 changes: 9 additions & 0 deletions docs/contributors.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Contributors
============
The following people have directly contributed code by way of new features
and/or bug fixes to Rmqtools:

- Christian Thompson
- Paul Horton

*Contributors listed by commit count.*
14 changes: 14 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Usage Examples
==============

Examples coming soon!
~~~~~~~~~~~~~~~~~~~~~

See ``examples/`` in the GitHub repository for now.

.. Rmqtools has various methods of use, between the high-level RmqConnection class
.. and the various lower-level classes. The following examples illustrate
.. different ways the RmqConnection class can be used to handle common use cases.

.. These examples, on the other hand, illustrate some ways in which the
.. lower-level API can be used for more specific use cases.
22 changes: 22 additions & 0 deletions docs/faq.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Frequently Asked Questions
==========================

- Is Rmqtools threaded?

The high-level API in the Rmqtools library, ``RmqConnection`` contains
mostly threaded methods, while the underlying classes are not threaded,
but can be threaded if desired. The important thing to remember when
threading is that each thread must have a unique connection, created in
that thread. See :doc:`/modules/rmq` for more details.

- How do I report a bug with Rmqtools?

The `main Rmqtools repository <https://github.com/ASTHROS/rmqtools>`_
is hosted on `GitHub <https://github.com>`_ and we use the
`Issue tracker <https://github.com/ASTHROS/rmqtools/issues>`_ to
handle bug reports.

- How can I contribute to Rmqtools?

You can fork the project on GitHub and issue Pull Requests when you believe
you have something solid to be added to the main repository.
62 changes: 62 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.. rmqtools documentation master file, created by
sphinx-quickstart on Thu Jun 29 13:22:51 2023.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

Welcome to Rmqtools!
====================
Rmqtools provides enhanced features for RabbitMQ development in Python. It is
based on the Pika_ library.

If you have not developed with Rmqtools, Pika, or RabbitMQ before, the
:doc:`intro` documentation is a good place to get started.

Installing Rmqtools
-------------------

Prerequisites
~~~~~~~~~~~~~

* Pika (`version 1.3.0+ <https://pika.readthedocs.io/en/stable/#installing-pika>`_)
* RabbitMQ (`version 3.12.0+ <https://rabbitmq.com/download.html>`_)

Note: Pika should be automatically installed when installing Rmqtools

Rmqtools is not currently available for download with PyPI. Once it is
available, it can be installed via pip::

pip install rmqtools

To install the latest version before Rmqtools is available on PyPI, use the
latest_ release on GitHub and download ``rmqtools-<version>-py3-none-any.whl``.
Then install the wheel file with pip::

pip install rmqtools-<version>-py3-none-any.whl

To install directly from source, run "python setup.py install" in the root
source directory.

Using Rmqtools
--------------
.. toctree::
:glob:
:maxdepth: 2

intro
modules/index
examples
faq
contributors


Indices and tables
------------------

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

.. aliases below here
.. _Pika: https://pika.readthedocs.io
.. _latest: https://github.com/ASTHROS/rmqtools/releases/latest
.. |repo_base| replace:: https://github.com/ASTHROS/rmqtools
65 changes: 65 additions & 0 deletions docs/intro.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Introduction to Rmqtools
========================
This introduction guide will cover the basics of using RabbitMQ and Rmqtools.
For more detailed information about the underlying Pika library, please read
`Pika's documentation <https://pika.readthedocs.org/en/stable/>`_. For more
information about the underlying RabbitMQ messaging system, please visit
`RabbitMQ's main site <https://rabbitmq.com/>`_.

High-level API
--------------
The high-level API consists of the RmqConnection class and the ResponseObject
structure. The high-level API implements wrappers for several common RabbitMQ
use cases. All methods in the high-level API are threaded, so as to make sure
that Pika's :class:`~pika.adapters.blocking_connection.BlockingConnection`
doesn't interfere with other connections. Essentially, the threading allows
for multiple concurrent producers and consumers to run in the same program.
Detailed documentation for the high-level API can be found at
:doc:`/modules/rmq`, and additional examples can be found in :doc:`/examples`.

Example of a publisher that publishes log messages once per second::

import rmqtools

rmq = rmqtools.RmqConnection(host='rabbit-1')
rmq.set_status_exchange('logs')

@rmq.publish_status(1, 'device.1.status')
def send_status():
status = 'running'
msg = {'status': status}
return msg

rmq.run()

Example of a subscriber that consumes those log messages::

import rmqtools
import json

rmq = rmqtools.RmqConnection(host='rabbit-1')
rmq.set_status_exchange('logs')

@rmq.subscribe_status('device_logs', 'device.*.status')
def handle_response(channel, method, props, body):
try:
data = json.loads(body)
except:
data = {'status': 'down'}
print(data.get('status'))

rmq.run()

Notice how each of these examples end in ``rmq.run()``. This is not a
coincidence, but rather a requirement. Any program that uses the high-level
API must always use the :py:meth:`RmqConnection.run` method at the end to
initiate the program. The method decorators in :class:`RmqConnection` create
threads, and the :py:meth:`RmqConnection.run` method starts all the threads
and waits for either user input or a system interrupt to stop the threads.

Low-level API
-------------
Coming soon!

More examples coming soon!
~~~~~~~~~~~~~~~~~~~~~~~~~~
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
13 changes: 13 additions & 0 deletions docs/modules/connection.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Connection
==========
.. automodule:: rmqtools.connection

Connection
----------
.. autoclass:: rmqtools.Connection
:members:
:member-order: bysource

.. autoclass:: rmqtools.ResponseObject
:members:
:member-order: bysource
12 changes: 12 additions & 0 deletions docs/modules/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Core Class and Module Documentation
===================================

.. toctree::
:glob:
:maxdepth: 1

rmq
rpc
publisher
subscriber
connection
9 changes: 9 additions & 0 deletions docs/modules/publisher.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Publisher
=========
.. automodule:: rmqtools.publisher

Publisher
---------
.. autoclass:: rmqtools.Publisher
:members:
:member-order: bysource
Loading