-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add hook possibility for consumers to configure themselves #428
Conversation
…fra#427 for example setup topic based on config, etc: fedora-infra#427
Codecov Report
@@ Coverage Diff @@
## develop #428 +/- ##
========================================
Coverage 47.15% 47.15%
========================================
Files 33 33
Lines 2059 2059
Branches 331 331
========================================
Hits 971 971
Misses 993 993
Partials 95 95
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, @glensc!
I agree with you that the consumer API is hard to work with and needs to be changed.
However, I'm hesitant to accept this for a few reasons. The first is that when I saw a configure
method on the class, my expectation was that it was an API to configure the consumer "from the outside". This looks like an API that should never be called by the creator of a consumer object. The second is that it introduces a second way to do something (initialize a consumer), which is confusing.
What I'd really like to do is flatten out the inheritance structure here by dropping Moksha as a dependency and defining our own consumer API. The combination of fewer layers of inheritance along with better error handling and reporting would, I think, do wonders for the usability of this. What I haven't done is come up with a concrete plan for getting rid of Moksha.
this actually does not work as expected. for #427 to be able to configure
because doing after but they both happen in parent class: so the current way, i see this could work, is to call on class MyConsumer(fedmsg.consumers.FedmsgConsumer):
config_key = "my_consumer_enabled"
def __init__(self, hub):
# I'm only interested in messages by this topic
self.topic = hub.config.get('my_topic')
super(MyConsumer, self).__init__(hub) |
That specific example probably won't work because |
the example given here, does work. i.e the same way you described: init ps: never link to branch, use commit or hash to ensure the link stays valid when branch is updated! |
actually, i wouldn't want to configure added locally to my code: def __init__(self, hub):
# listen to file commits
self.topic = self.abs_topic(hub.config, "my.key")
super(CVSConsumer, self).__init__(hub)
# no proper way to configure just topic suffix
# https://github.com/fedora-infra/fedmsg/pull/428
def abs_topic(self, config, topic):
"""
prefix topic with topic_prefix and environment config values
"""
topic_prefix = config.get('topic_prefix')
environment = config.get('environment')
return "%s.%s.%s" % (topic_prefix, environment, topic) |
@jeremycline here's my project i'm working on: https://github.com/glensc/fedmsg-cvs i don't mind if you do small codereview there and perhaps open ticket about problems/solutions how to do things better. it "works", but likely doesn't use any best practices |
Hey @glensc, I know we talked about some of your issues with fedmsg-cvs on IRC. Are you good to go? I'm pretty new to fedmsg myself, so I'm not sure about best practices either. As I outlined above, I'd really like to make this whole process easier. However, in my opinion adding this API will just muddy the waters further. However, I really appreciate you highlighting this issue and submitting this PR! |
proposed solution for #427
add hook possibility for consumers to configure themselves,
for example setup topic based on config, etc