| Name | netlink-ipc JSON |
| Version |
3.0.0
JSON |
| download |
| home_page | |
| Summary | A Basic inter-process communication (IPC) library for Client to Server communication. |
| upload_time | 2023-09-10 12:12:52 |
| maintainer | |
| docs_url | None |
| author | Suffxr |
| requires_python | >=3.8 |
| license | |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# NetLink
NetLink is a Python library for client-to-server communication, designed to simplify the process of building networked applications. It provides a simple way to establish communication between clients and servers.
## Features
- Easy setup and integration into your Python projects.
- Secure authentication using a secret key.
- Supports multiple routes for handling different types of requests.
- Error handling for common communication issues.
- Asynchronous support for improved performance.
## Installation
```
python -m pip install netlink_ipc
```
## Examples
# Server
- Setting up a server with NetLink is straightforward. Here's an example of how to create a basic server:
```py
from netlink import NetLinkServer, Payload
# Initialize the server with a host, port, and secret key
server = NetLinkServer(host="0.0.0.0", port=3000, secret_key="my_secret_key")
# Define a route and the corresponding function
@server.route(name="greet") # We can either pass a name or not, if no name is given the function name is used
def greet(payload: Payload):
return f"Hello, {payload.name}!"
# Start the server
server.start()
```
# Client
- Connecting to the server and sending requests from the client is equally easy:
```py
from netlink import NetLinkClient
# Initialize the client with the server's host, port, and secret key
client = NetLinkClient(host="127.0.0.1", port=3000, secret_key="my_secret_key")
# Send a request to the "greet" route with a name kwarg
response = client.request("greet", name="Bob")
# Print the ServerResponse, response
print(response.response)
```
## Asynchronous Examples
# Server
- NetLink supports asynchronous communication for improved performance. Here's an example of an asynchronous server:
```py
import asyncio
from netlink import NetLinkAsyncServer, Payload
server = NetLinkAsyncServer(host="0.0.0.0", port=3000, secret_key="my_secret_key")
@server.route(name="greet")
async def greet(payload: Payload):
return f"Hello, {payload.name}!"
async def main():
await server.start()
asyncio.run(main())
```
# Client
- Here's an example of an asynchronous client:
```py
import asyncio
from netlink import NetLinkAsyncClient
async def main():
client = NetLinkAsyncClient(host="127.0.0.1", port=3000, secret_key="my_secret_key")
response = await client.request("greet", name="Bob")
print(response)
# Run the asynchronous client and request the 'greet' route
asyncio.run(main())
```
Raw data
{
"_id": null,
"home_page": "",
"name": "netlink-ipc",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "",
"author": "Suffxr",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/c4/6a/ad5bed92d4acf2e4de1ec503a78bb1f86577bfd825fd46e2a15e207223b4/netlink_ipc-3.0.0.tar.gz",
"platform": null,
"description": "# NetLink\r\n\r\nNetLink is a Python library for client-to-server communication, designed to simplify the process of building networked applications. It provides a simple way to establish communication between clients and servers.\r\n\r\n## Features\r\n\r\n- Easy setup and integration into your Python projects.\r\n- Secure authentication using a secret key.\r\n- Supports multiple routes for handling different types of requests.\r\n- Error handling for common communication issues.\r\n- Asynchronous support for improved performance.\r\n\r\n## Installation\r\n\r\n```\r\npython -m pip install netlink_ipc\r\n```\r\n\r\n## Examples\r\n\r\n# Server\r\n- Setting up a server with NetLink is straightforward. Here's an example of how to create a basic server:\r\n```py\r\nfrom netlink import NetLinkServer, Payload\r\n\r\n# Initialize the server with a host, port, and secret key\r\nserver = NetLinkServer(host=\"0.0.0.0\", port=3000, secret_key=\"my_secret_key\")\r\n\r\n# Define a route and the corresponding function\r\n@server.route(name=\"greet\") # We can either pass a name or not, if no name is given the function name is used\r\ndef greet(payload: Payload):\r\n return f\"Hello, {payload.name}!\"\r\n\r\n# Start the server\r\nserver.start()\r\n```\r\n\r\n# Client\r\n- Connecting to the server and sending requests from the client is equally easy:\r\n```py\r\nfrom netlink import NetLinkClient\r\n\r\n# Initialize the client with the server's host, port, and secret key\r\nclient = NetLinkClient(host=\"127.0.0.1\", port=3000, secret_key=\"my_secret_key\")\r\n\r\n# Send a request to the \"greet\" route with a name kwarg\r\nresponse = client.request(\"greet\", name=\"Bob\")\r\n\r\n# Print the ServerResponse, response\r\nprint(response.response)\r\n```\r\n\r\n## Asynchronous Examples\r\n\r\n\r\n# Server\r\n- NetLink supports asynchronous communication for improved performance. Here's an example of an asynchronous server:\r\n```py\r\nimport asyncio\r\nfrom netlink import NetLinkAsyncServer, Payload\r\n\r\nserver = NetLinkAsyncServer(host=\"0.0.0.0\", port=3000, secret_key=\"my_secret_key\")\r\n\r\n@server.route(name=\"greet\")\r\nasync def greet(payload: Payload):\r\n return f\"Hello, {payload.name}!\"\r\n\r\nasync def main():\r\n await server.start()\r\n\r\nasyncio.run(main())\r\n```\r\n\r\n# Client\r\n- Here's an example of an asynchronous client:\r\n```py\r\nimport asyncio\r\nfrom netlink import NetLinkAsyncClient\r\n\r\nasync def main():\r\n client = NetLinkAsyncClient(host=\"127.0.0.1\", port=3000, secret_key=\"my_secret_key\")\r\n\r\n response = await client.request(\"greet\", name=\"Bob\")\r\n\r\n print(response)\r\n\r\n# Run the asynchronous client and request the 'greet' route\r\nasyncio.run(main())\r\n```\r\n",
"bugtrack_url": null,
"license": "",
"summary": "A Basic inter-process communication (IPC) library for Client to Server communication.",
"version": "3.0.0",
"project_urls": {
"Homepage": "https://github.com/pypa/sampleproject"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "25cbfbc1743e03d30aa2aec917833c9221d26037953bb2b9f2f60844be4312c5",
"md5": "8a52643d19d2fbe500e45f396534acb6",
"sha256": "f3f3d425c60f61aab1218c18ee959fde1063b9dbb06c8626225c197ea556aac6"
},
"downloads": -1,
"filename": "netlink_ipc-3.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8a52643d19d2fbe500e45f396534acb6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 7399,
"upload_time": "2023-09-10T12:12:50",
"upload_time_iso_8601": "2023-09-10T12:12:50.216676Z",
"url": "https://files.pythonhosted.org/packages/25/cb/fbc1743e03d30aa2aec917833c9221d26037953bb2b9f2f60844be4312c5/netlink_ipc-3.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c46aad5bed92d4acf2e4de1ec503a78bb1f86577bfd825fd46e2a15e207223b4",
"md5": "cb84971fe763dbeae0b025e5b9485a94",
"sha256": "78742e107eae67b9b90aa3eb76493edd6cff05bc66a3180569d744281eb95c44"
},
"downloads": -1,
"filename": "netlink_ipc-3.0.0.tar.gz",
"has_sig": false,
"md5_digest": "cb84971fe763dbeae0b025e5b9485a94",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 6584,
"upload_time": "2023-09-10T12:12:52",
"upload_time_iso_8601": "2023-09-10T12:12:52.099351Z",
"url": "https://files.pythonhosted.org/packages/c4/6a/ad5bed92d4acf2e4de1ec503a78bb1f86577bfd825fd46e2a15e207223b4/netlink_ipc-3.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-10 12:12:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pypa",
"github_project": "sampleproject",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "netlink-ipc"
}