commlink


Namecommlink JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryZeroMQ-based publisher/subscriber and RPC utilities
upload_time2025-10-21 18:06:03
maintainerNone
docs_urlNone
authorCommlink Maintainers
requires_python>=3.9
licenseMIT License Copyright (c) 2024 Commlink Maintainers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords zeromq messaging rpc pubsub
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Commlink

Commlink exposes a lightweight Remote Procedure Call (RPC) layer on top of [ZeroMQ](https://zeromq.org/) that lets you interact
with objects running in a different process or host as if they were local. You can wrap any existing object with a single line
and obtain a client-side proxy that transparently mirrors attribute access, mutation, and callable invocation for anything that
can be pickled. Simple publisher/subscriber helpers are also available for broadcast-style messaging when you need them.

## Installation

```bash
pip install commlink
```

## RPC quickstart

### Server

```python
from commlink import RPCServer


class TemperatureController:
    def __init__(self):
        self.target_celsius = 20

    def get_reading(self):
        """Pretend to talk to a sensor and return the current reading."""
        return self.target_celsius

    def setpoint(self, value):
        self.target_celsius = value
        return f"Set target temperature to {value}°C"


if __name__ == "__main__":
    # Wrap the object with a one-line RPC server. The server runs in a background thread by default.
    server = RPCServer(TemperatureController(), port=6000)
    server.start()
    server.thread.join()  # Optional: keep the process alive while the server thread runs.
```

### Client

```python
from commlink import RPCClient

# Instantiate the remote object locally – attribute access, setters, and method calls all proxy to the server.
controller = RPCClient("localhost", port=6000)

print(controller.get_reading())  # Call remote methods with any pickle-able arguments or return values.
print(controller.setpoint(25))

controller.target_celsius = 18  # Mutate attributes on the remote instance.
print(controller.target_celsius)

# When you're finished, politely stop the remote server.
controller.stop_server()
```

### RPC capabilities

* **Transparent calls** – Functions and methods execute remotely with arbitrary pickle-able arguments and return values.
* **Attribute access** – Reading or setting attributes forwards the operation to the remote object.
* **Drop-in adoption** – Wrap any pre-existing object with `RPCServer(obj, ...)` and obtain a live proxy by instantiating
  `RPCClient(host, port)`.
* **Threaded by default** – `RPCServer` starts in a background thread so your host application can continue doing work or cleanly
  manage lifecycle events.

## Publisher/subscriber helpers

If you also need broadcast-style messaging, Commlink ships with simple ZeroMQ publishers and subscribers:

```python
from commlink import Publisher, Subscriber

publisher = Publisher("*", port=5555)
subscriber = Subscriber("localhost", port=5555, topics=["updates"])

publisher.publish("updates", {"message": "Hello, world!"})
print(subscriber.get())
```

## Development

Run the automated test suite with:

```bash
pytest
```

## License

Commlink is distributed under the terms of the [MIT License](./LICENSE).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "commlink",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "zeromq, messaging, rpc, pubsub",
    "author": "Commlink Maintainers",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/53/63/94131889af0637bc02952180ff4af0c79db3c1462912383d9b5c73a9bb16/commlink-0.1.1.tar.gz",
    "platform": null,
    "description": "# Commlink\n\nCommlink exposes a lightweight Remote Procedure Call (RPC) layer on top of [ZeroMQ](https://zeromq.org/) that lets you interact\nwith objects running in a different process or host as if they were local. You can wrap any existing object with a single line\nand obtain a client-side proxy that transparently mirrors attribute access, mutation, and callable invocation for anything that\ncan be pickled. Simple publisher/subscriber helpers are also available for broadcast-style messaging when you need them.\n\n## Installation\n\n```bash\npip install commlink\n```\n\n## RPC quickstart\n\n### Server\n\n```python\nfrom commlink import RPCServer\n\n\nclass TemperatureController:\n    def __init__(self):\n        self.target_celsius = 20\n\n    def get_reading(self):\n        \"\"\"Pretend to talk to a sensor and return the current reading.\"\"\"\n        return self.target_celsius\n\n    def setpoint(self, value):\n        self.target_celsius = value\n        return f\"Set target temperature to {value}\u00b0C\"\n\n\nif __name__ == \"__main__\":\n    # Wrap the object with a one-line RPC server. The server runs in a background thread by default.\n    server = RPCServer(TemperatureController(), port=6000)\n    server.start()\n    server.thread.join()  # Optional: keep the process alive while the server thread runs.\n```\n\n### Client\n\n```python\nfrom commlink import RPCClient\n\n# Instantiate the remote object locally \u2013 attribute access, setters, and method calls all proxy to the server.\ncontroller = RPCClient(\"localhost\", port=6000)\n\nprint(controller.get_reading())  # Call remote methods with any pickle-able arguments or return values.\nprint(controller.setpoint(25))\n\ncontroller.target_celsius = 18  # Mutate attributes on the remote instance.\nprint(controller.target_celsius)\n\n# When you're finished, politely stop the remote server.\ncontroller.stop_server()\n```\n\n### RPC capabilities\n\n* **Transparent calls** \u2013 Functions and methods execute remotely with arbitrary pickle-able arguments and return values.\n* **Attribute access** \u2013 Reading or setting attributes forwards the operation to the remote object.\n* **Drop-in adoption** \u2013 Wrap any pre-existing object with `RPCServer(obj, ...)` and obtain a live proxy by instantiating\n  `RPCClient(host, port)`.\n* **Threaded by default** \u2013 `RPCServer` starts in a background thread so your host application can continue doing work or cleanly\n  manage lifecycle events.\n\n## Publisher/subscriber helpers\n\nIf you also need broadcast-style messaging, Commlink ships with simple ZeroMQ publishers and subscribers:\n\n```python\nfrom commlink import Publisher, Subscriber\n\npublisher = Publisher(\"*\", port=5555)\nsubscriber = Subscriber(\"localhost\", port=5555, topics=[\"updates\"])\n\npublisher.publish(\"updates\", {\"message\": \"Hello, world!\"})\nprint(subscriber.get())\n```\n\n## Development\n\nRun the automated test suite with:\n\n```bash\npytest\n```\n\n## License\n\nCommlink is distributed under the terms of the [MIT License](./LICENSE).\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2024 Commlink Maintainers\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.\n        ",
    "summary": "ZeroMQ-based publisher/subscriber and RPC utilities",
    "version": "0.1.1",
    "project_urls": null,
    "split_keywords": [
        "zeromq",
        " messaging",
        " rpc",
        " pubsub"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "204bf6999d03cb4ca048d00120cea09362a73684572e489e018d7ac50ed7098f",
                "md5": "03ba9ea326edb6afdf1a0fb39abccff0",
                "sha256": "438303aeed35debf187d11d36f99ec20c1ff78e83a3e8e8d966af0fe5595efb9"
            },
            "downloads": -1,
            "filename": "commlink-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "03ba9ea326edb6afdf1a0fb39abccff0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 9220,
            "upload_time": "2025-10-21T18:06:02",
            "upload_time_iso_8601": "2025-10-21T18:06:02.125307Z",
            "url": "https://files.pythonhosted.org/packages/20/4b/f6999d03cb4ca048d00120cea09362a73684572e489e018d7ac50ed7098f/commlink-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "536394131889af0637bc02952180ff4af0c79db3c1462912383d9b5c73a9bb16",
                "md5": "bb8d5d16b4b9a48d284859222f05dea0",
                "sha256": "45fc67ee2b2aba3d4383fa8c3af8609fd93cfc31bcce6285dd83f00e204b722e"
            },
            "downloads": -1,
            "filename": "commlink-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "bb8d5d16b4b9a48d284859222f05dea0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 9984,
            "upload_time": "2025-10-21T18:06:03",
            "upload_time_iso_8601": "2025-10-21T18:06:03.315339Z",
            "url": "https://files.pythonhosted.org/packages/53/63/94131889af0637bc02952180ff4af0c79db3c1462912383d9b5c73a9bb16/commlink-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-21 18:06:03",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "commlink"
}
        
Elapsed time: 1.78454s