Skip to content

Commit

Permalink
Add template for event emitter plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
benthomasson committed Oct 12, 2023
1 parent ad268aa commit 2827e1b
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions extensions/eda/plugins/event_emitter/template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env python3
"""
template.py
An ansible-rulebook event emitter plugin template.
Examples:
sources:
- template:
"""
import asyncio
from typing import Any, Dict


async def main(queue: asyncio.Queue, args: Dict[str, Any]):
delay = args.get("delay", 0)

while True:
message = await queue.get()
if message is None:
break
print(message)


if __name__ == "__main__":

class MockQueue:
count = 10
async def get(self):
self.count -= 1
if self.count == 0:
return None
else:
return {'message': 'hello world'}

mock_arguments = dict()
asyncio.run(main(MockQueue(), mock_arguments))

0 comments on commit 2827e1b

Please sign in to comment.