Merge lp:~james-w/python-oops-amqp/new-publisher-api into lp:python-oops-amqp

Proposed by James Westby
Status: Needs review
Proposed branch: lp:~james-w/python-oops-amqp/new-publisher-api
Merge into: lp:python-oops-amqp
Diff against target: 68 lines (+11/-9)
4 files modified
README (+1/-0)
oops_amqp/__init__.py (+8/-7)
oops_amqp/tests/test_publisher.py (+1/-2)
versions.cfg (+1/-0)
To merge this branch: bzr merge lp:~james-w/python-oops-amqp/new-publisher-api
Reviewer Review Type Date Requested Status
Robert Collins Pending
Review via email: mp+112951@code.launchpad.net

Commit message

Provide the new publisher API.

Description of the change

Hi,

Here's a sketch of how the new publisher API could be provided in
oops_amqp.

I think the name is terrible, so suggestions are welcome.

Thanks,

James

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

A few thoughts: we decided to whine on all legacy publishers in the
oops codebase, so there is little reason to preserve compat here: when
someone updates they can just move the publisher to the new config. As
such, I'd not change the name.

That should make the patch quite a bit smaller.

Revision history for this message
James Westby (james-w) wrote :

Hi Rob,

On Sun, 01 Jul 2012 22:07:21 -0000, Robert Collins <email address hidden> wrote:
> A few thoughts: we decided to whine on all legacy publishers in the
> oops codebase, so there is little reason to preserve compat here: when
> someone updates they can just move the publisher to the new config. As
> such, I'd not change the name.
>
> That should make the patch quite a bit smaller.

Indeed.

The reason I didn't do this was firstly out of principle that API breaks
are bad, but primarily because we use this code from a package, so there
may be other users.

I can still do the compatibility break, but it requires auditing other
users, and perhaps a multi-project lockstep change.

What do you think?

Thanks,

James

Revision history for this message
Robert Collins (lifeless) wrote :

Well, this is why I think using python from packages today is a poor
idea. The lack of an ABI makes for great friction between developer
good practices and deployment good practices - and see how the python
community is consolidating around workarounds like buildout and
virtualenv.

That said, package rdepends should let you determine users in our
environment pretty reliable, and its still young-time for the project,
so I think it should be fine, long as we don't mess around and get it
done.

Up to you though.

12. By James Westby

Switch to breaking API rather than adding a new Publisher object.

Also update the users of the publish() API in the test-suite to expect
the new behaviour.

13. By James Westby

Update the requirements to demand the new API from oops.

14. By James Westby

Merge trunk.

Revision history for this message
Robert Collins (lifeless) wrote :

So I think you should probably just land this, as time is ticking on the change being harder to do if more people start using oops. I'm not really maintaining it anymore...

Unmerged revisions

14. By James Westby

Merge trunk.

13. By James Westby

Update the requirements to demand the new API from oops.

12. By James Westby

Switch to breaking API rather than adding a new Publisher object.

Also update the users of the publish() API in the test-suite to expect
the new behaviour.

11. By James Westby

A sketch of the new publisher API in oops_amqp.

PublisherV2 is a bad name.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README'
2--- README 2012-08-10 01:41:44 +0000
3+++ README 2013-03-11 20:26:18 +0000
4@@ -86,6 +86,7 @@
5 you wrap the fallback publisher so that it only gets invoked if the primary
6 method failed::
7
8+ >>> from oops.publishers import publish_with_fallback
9 >>> fallback_factory = partial(amqp.Connection, host="otherserver:5672",
10 ... userid="guest", password="guest", virtual_host="/", insist=False)
11 >>> fallback_publisher = oops_amqp.Publisher(fallback_factory, "oopses", "")
12
13=== modified file 'oops_amqp/__init__.py'
14--- oops_amqp/__init__.py 2012-08-10 03:06:16 +0000
15+++ oops_amqp/__init__.py 2013-03-11 20:26:18 +0000
16@@ -53,14 +53,15 @@
17 ---------------------
18
19 From time to time your AMQP server may be unavailable. If that happens then
20-the Publisher will not assign an oops id - it will return None to signal that
21-the publication failed. To prevent losing the OOPS its a good idea to have a
22-fallback publisher - either another AMQP publisher (to a different server) or
23-one that spools locally (where you can pick up the OOPSes via rsync or some
24-other mechanism. Using the oops standard helper publish_with_fallback will let
25-you wrap the fallback publisher so that it only gets invoked if the primary
26-method failed::
27+the Publisher will not assign an oops id - it will return an empty list
28+to signal that the publication failed. To prevent losing the OOPS its a good
29+idea to have a fallback publisher - either another AMQP publisher (to a
30+different server) or one that spools locally (where you can pick up the OOPSes
31+via rsync or some other mechanism. Using the oops standard helper
32+publish_with_fallback will let you wrap the fallback publisher so that it only
33+gets invoked if the primary method failed::
34
35+ >>> from oops.publishers import publish_with_fallback
36 >>> fallback_factory = partial(amqp.Connection, host="otherserver:5672",
37 ... userid="guest", password="guest", virtual_host="/", insist=False)
38 >>> fallback_publisher = oops_amqp.Publisher(fallback_factory, "oopses", "")
39
40=== modified file 'oops_amqp/tests/test_publisher.py'
41--- oops_amqp/tests/test_publisher.py 2012-08-10 01:41:44 +0000
42+++ oops_amqp/tests/test_publisher.py 2013-03-11 20:26:18 +0000
43@@ -113,7 +113,7 @@
44 queue = self.useFixture(QueueFixture(channel, self.getUniqueString))
45 publisher = Publisher(self.connection_factory, queue.exchange_name, "")
46 oops = {'akey': 42}
47- self.assertNotEqual(None, publisher(oops))
48+ self.assertNotEqual([], publisher(oops))
49 # The private method use and the restart of rabbit before it gets torn
50 # down are bugs in rabbitfixture that will be fixed in a future
51 # release.
52@@ -124,4 +124,3 @@
53 self.rabbit.runner._start()
54 queue.channel = self.connection_factory().channel()
55 self.assertNotEqual([], publisher(oops))
56-
57
58=== modified file 'versions.cfg'
59--- versions.cfg 2012-08-10 01:41:44 +0000
60+++ versions.cfg 2013-03-11 20:26:18 +0000
61@@ -5,6 +5,7 @@
62 amqplib = 0.6.1
63 bson = 0.3.2
64 fixtures = 0.3.6
65+distribute = 0.6.24
66 iso8601 = 0.1.4
67 oops = 0.0.13
68 pymongo = 2.1.1

Subscribers

People subscribed via source and target branches

to all changes: