Skip to main content

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.startup()
    while True:
        time.sleep(.1)
except KeyboardInterrupt:
    moss.shutdown()

Project details


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.8.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tinymoss-0.0.8-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file tinymoss-0.0.8.tar.gz.

File metadata

  • Download URL: tinymoss-0.0.8.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for tinymoss-0.0.8.tar.gz
Algorithm Hash digest
SHA256 0bc42887988e2e38936e0ca3ac2c786525372a3432a4d96b7a8175ffb3ed94e6
MD5 a107b43ec21d382628b04d7931c05601
BLAKE2b-256 c546508dc817f381e01d26371092cc2c74287b66e2ebf122cc463b1b6010be2c

See more details on using hashes here.

File details

Details for the file tinymoss-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: tinymoss-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for tinymoss-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 523b0a04c12c970e054597fae1f6f9ae596b873cb3d83ec04afbe3f721f39903
MD5 7aff2ad6bc54d91314167ba6bb15e64a
BLAKE2b-256 01c68429cf567aad8273a32f02e06bac5c9c58872813412eb34c78440132c28b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page