Skip to content

Commit

Permalink
Adding Pub/Sub examples
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBurchLog committed Nov 7, 2023
1 parent d3c39ee commit 234b3f3
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 0 deletions.
1 change: 1 addition & 0 deletions publisher/beer.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PLUGIN_ENTRY="-m publisher"
Empty file added publisher/publisher/__init__.py
Empty file.
28 changes: 28 additions & 0 deletions publisher/publisher/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import logging

from brewtils import PublishClient, Plugin, command

__version__ = "3.0.0.dev0"

class Publisher:

def __init__(self):
self.publishClient = publishClient

@command()
def publish_topics(self, payload:dict, topic:str = "topic1") -> dict:
return dict

def main():
plugin = Plugin(
name="publisher",
version=__version__,
description="A plugin that publishes to topics",
max_concurrent=1,
)
plugin.client = Publisher()
plugin.run()


if __name__ == "__main__":
main()
41 changes: 41 additions & 0 deletions publisher/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import re

from setuptools import setup


def find_version(version_file):
version_line = open(version_file, "rt").read()
match_object = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_line, re.M)

if not match_object:
raise RuntimeError("Unable to find version string in %s" % version_file)

return match_object.group(1)


setup(
name="publisher",
version=find_version("publisher/__main__.py"),
description="A plugin that publishes to topics",
url="https://beer-garden.io",
author="The Beergarden Team",
author_email=" ",
license="MIT",
packages=["publisher"],
install_requires=["brewtils"],
classifiers=[
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
)
1 change: 1 addition & 0 deletions subscribe/beer.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PLUGIN_ENTRY="-m subscribe"
41 changes: 41 additions & 0 deletions subscribe/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import re

from setuptools import setup


def find_version(version_file):
version_line = open(version_file, "rt").read()
match_object = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_line, re.M)

if not match_object:
raise RuntimeError("Unable to find version string in %s" % version_file)

return match_object.group(1)


setup(
name="subscribe",
version=find_version("subscribe/__main__.py"),
description="A plugin that subscribes to topics",
url="https://beer-garden.io",
author="The Beergarden Team",
author_email=" ",
license="MIT",
packages=["subscribe"],
install_requires=["brewtils"],
classifiers=[
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
)
Empty file added subscribe/subscribe/__init__.py
Empty file.
33 changes: 33 additions & 0 deletions subscribe/subscribe/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import logging

from brewtils import subscribe, Plugin

__version__ = "3.0.0.dev0"

class SubscribeClient:

@subscribe(topics=["topic1","topic2"])
def subscribe_multiple_topics(self, payload:dict) -> dict:
return dict

@subscribe(topics="topic1")
def subscrib_one_topics(self, payload:dict) -> dict:
return dict

@subscribe(topics="topic.*")
def subscribe_wildcard_topics(self, payload:dict) -> dict:
return dict

def main():
plugin = Plugin(
name="subscribe",
version=__version__,
description="A plugin that subscribes to topics",
max_concurrent=1,
)
plugin.client = SubscribeClient()
plugin.run()


if __name__ == "__main__":
main()

0 comments on commit 234b3f3

Please sign in to comment.