Skip to content

Commit 2827e1b

Browse files
committed
Add template for event emitter plugins
1 parent ad268aa commit 2827e1b

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env python3
2+
"""
3+
template.py
4+
5+
An ansible-rulebook event emitter plugin template.
6+
7+
Examples:
8+
sources:
9+
- template:
10+
11+
"""
12+
import asyncio
13+
from typing import Any, Dict
14+
15+
16+
async def main(queue: asyncio.Queue, args: Dict[str, Any]):
17+
delay = args.get("delay", 0)
18+
19+
while True:
20+
message = await queue.get()
21+
if message is None:
22+
break
23+
print(message)
24+
25+
26+
if __name__ == "__main__":
27+
28+
class MockQueue:
29+
count = 10
30+
async def get(self):
31+
self.count -= 1
32+
if self.count == 0:
33+
return None
34+
else:
35+
return {'message': 'hello world'}
36+
37+
mock_arguments = dict()
38+
asyncio.run(main(MockQueue(), mock_arguments))
39+

0 commit comments

Comments
 (0)