Skip to content
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

dynamic config support #454

Open
glensc opened this issue Jul 20, 2017 · 2 comments
Open

dynamic config support #454

glensc opened this issue Jul 20, 2017 · 2 comments

Comments

@glensc
Copy link
Contributor

glensc commented Jul 20, 2017

spew from #428

i wish to listen to topic, but not to hardcode it to code, because the prefix may differ.

i solved this in my project this way:

    def __init__(self, hub):
        # I'm only interested in messages from CVS
        self.topic = self.abs_topic(hub.config, "cvs.commit")

        super(CVS2SlackConsumer, 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)

please provide official support for such approach, perhaps just implement abs_topic() fedmsg.consumers.FedmsgConsumer until new config system is in place.

i'm duplicating this logic in consumers i write for now, which is just bad practice.

@glensc
Copy link
Contributor Author

glensc commented Jul 20, 2017

other idea is to add self.topic_suffix aside self.topic which __init__ can handle the way above code does.

@jeremycline
Copy link
Member

This makes sense to me. A pattern I've seen through-out Fedora's consumers is a "Am I in dev/stg/prod? search-and-replace the topic I listen to" approach which is not very pleasant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants