Skip to content

Commit

Permalink
Add Zocalo config plugin to set default transport
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthchirp committed Oct 7, 2021
1 parent 5425406 commit 73ba66b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ workflows.transport =
zocalo.configuration.plugins =
pika = workflows.util.zocalo.configuration:Pika
stomp = workflows.util.zocalo.configuration:Stomp
transport = workflows.util.zocalo.configuration:DefaultTransport

[options.packages.find]
where = src
Expand Down
12 changes: 12 additions & 0 deletions src/workflows/util/zocalo/configuration.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from marshmallow import fields
from zocalo.configuration import PluginSchema

import workflows.transport
from workflows.transport.pika_transport import PikaTransport
from workflows.transport.stomp_transport import StompTransport

Expand Down Expand Up @@ -47,3 +48,14 @@ def activate(configuration):
("vhost", "--rabbit-vhost"),
]:
PikaTransport.defaults[target] = configuration[cfgoption]


class DefaultTransport:
"""A Zocalo configuration plugin to set a default transport class"""

class Schema(PluginSchema):
default = fields.Str(required=True)

@staticmethod
def activate(configuration):
workflows.transport.default_transport = configuration["default"]

0 comments on commit 73ba66b

Please sign in to comment.