A ROS-like system called tiny moss
Project description
TinyMoss
基于RabbitMQ的轻量级分布式消息开发框架。
快速使用
安装 RabbitMQ
安装库
pip install tinymoss
项目结构
project --- 项目目录
|--- app.py 主入口程序
|--- moss.nodes.json 节点配置文件
|--- nodes 自定义节点目录
|--- node1 noed1节点
|--- __init__.py 初始化文件
|--- node1.py node1节点的具体实现
|--- node2 noed2节点
|--- __init__.py 初始化文件
|--- node2.py node2节点的具体实现
定义节点
# node1.py
class HelloNode(MossNode):
_should_shutup = False
def on_running(self):
print('Hello Node is running')
while not self._should_shutup:
time.sleep(5)
self.pub_to_service('<Other Node Service Id>', 'Hi!')
def on_messaged(self, route, body):
data = str (body, 'utf-8')
print(f'[Rx] {route}, {data}')
if route == 'urn:node:id:5cf3ed19-571d-4631-9bb0-e62de70bedea:service:shutup':
self._should_shutup = True
配置节点
{
"amqp": "amqp://guest:guest@localhost:5672/%2F",
"nodes": [
{
"id": "urn:node:id:5cf3ed19-571d-4631-9bb0-e62de70bedea",
"pacakge": "nodes/node1",
"name": "HelloNode",
"nodeData": {},
"services":[
"urn:node:id:5cf3ed19-571d-4631-9bb0-e62de70bedea:service:shutup"
],
"config": {}
}
]
}
调起 TinyMoss
from tinymoss import TinyMoss
moss = TinyMoss()
try:
moss.start()
while True:
time.sleep(.1)
except KeyboardInterrupt:
moss.shutdown()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tinymoss-0.0.7.tar.gz
(11.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tinymoss-0.0.7.tar.gz.
File metadata
- Download URL: tinymoss-0.0.7.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b86df52287311a8f7349c3b79d16ad4257bb31cd824b0f18dc38aaefba345dfb
|
|
| MD5 |
d282bb264e48108009baa702326e7a94
|
|
| BLAKE2b-256 |
b694683999b0bc32888b58ab17a268bf46ff17969f9fdb496b11b98ad4ff3aec
|
File details
Details for the file tinymoss-0.0.7-py3-none-any.whl.
File metadata
- Download URL: tinymoss-0.0.7-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c1560645b0ae0f8236d147ad4241e84f220ac79ef3ef242c3484ae6dbc0143c
|
|
| MD5 |
c8991a1d7c61b2de4e2c76c246bb58b4
|
|
| BLAKE2b-256 |
f1d679e600dae7807a43e3a84f9a5a830a9fec97f2b62bbd72e2c414c9c83539
|