Package: oops-amqp
**************************************************python-oops-amqp: Transmit error reports over amqp**************************************************Copyright (c) 2011, Canonical LtdThis program is free software: you can redistribute it and/or modifyit under the terms of the GNU Lesser General Public License as published bythe Free Software Foundation, version 3 only.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU Lesser General Public License for more details.You should have received a copy of the GNU Lesser General Public Licensealong with this program.  If not, see <http://www.gnu.org/licenses/>.GNU Lesser General Public License version 3 (see the file LICENSE).The oops_amqp package provides an AMQP OOPS (https://pypi.org/project/oops)publisher, and a small daemon that listens on amqp for OOPS reports andrepublishes them (into a supplied publisher). The OOPS framework permitsfalling back to additional publishers if AMQP is down.Dependencies============* Python 2.6+* bson* oops (https://pypi.org/project/oops) 0.0.11 or newer.* amqpTesting Dependencies====================* pytest (https://pypi.org/project/pytest)* rabbitfixture (https://pypi.org/project/rabbitfixture)Usage=====Publishing to AMQP++++++++++++++++++Where you are creating OOPS reports, configure oops_amqp.Publisher. This takesa connection factory - a simple callable that creates an amqpconnection - and the exchange name and routing key to submit to.>>> factory = partial(amqp.Connection, host="localhost:5672",...     userid="guest", password="guest", virtual_host="/")>>> publisher = oops_amqp.Publisher(factory, "oopses", "")Provide the publisher to your OOPS config::>>> config = oops.Config()>>> config.publisher = publisherAny oops published via that config will now be sent via amqp.OOPS ids are generating by hashing the oops message (without the id field) -this ensures unique ids.The reason a factory is used is because amqp is not threadsafe - thepublisher maintains a thread locals object to hold the factories and createsconnections when new threads are created(when they first generate an OOPS).Dealing with downtime---------------------From time to time your AMQP server may be unavailable. If that happens thenthe Publisher will not assign an oops id - it will return None to signal thatthe publication failed. To prevent losing the OOPS its a good idea to have afallback publisher - either another AMQP publisher (to a different server) orone that spools locally (where you can pick up the OOPSes via rsync or someother mechanism. Using the oops standard helper publish_with_fallback will letyou wrap the fallback publisher so that it only gets invoked if the primarymethod failed::>>> fallback_factory = partial(amqp.Connection, host="otherserver:5672",...     userid="guest", password="guest", virtual_host="/")>>> fallback_publisher = oops_amqp.Publisher(fallback_factory, "oopses", "")>>> config.publisher = publish_with_fallback(publisher, fallback_publisher)Receiving from AMQP+++++++++++++++++++There is a simple method that will run an infinite loop processing reports fromAMQP. To use it you need to configure a local config to publish the receivedreports. A full config is used because that includes support for filtering(which can be useful if you need to throttle volume, for instance).Additionally you need an amqp connection factory (to handle the amqp serverbeing restarted) and a queue name to receive from.This example uses the DateDirRepo publisher, telling it to accept whateverid was assigned by the process publishing to AMQP::>>> publisher = oops_datedir_repo.DateDirRepo('.', inherit_id=True)>>> config = oops.Config()>>> config.publisher = publisher.publish>>> receiver = oops_amqp.Receiver(config, factory, "my queue")>>> receiver.run_forever()For more information see pydoc oops_amqp.Installation============Either run setup.py in an environment with all the dependencies available, oradd the working directory to your PYTHONPATH.Development===========Upstream development takes place at https://launchpad.net/python-oops-amqp.To run the tests, use ``tox``.