slicpy


Nameslicpy JSON
Version 0.0.9 PyPI version JSON
download
home_pagehttps://github.com/teddyoweh/SLIC
SummarySwift Low-latency Intercommunication
upload_time2023-05-16 03:42:55
maintainer
docs_urlNone
authorTeddy Oweh
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SLIC - (Swift Low-latency Intercommunication)

SLIC (Swift Low-latency Intercommunication) simplifies client-server communication using tcp / p2p protocols while focusing on latency reduction through low-latency intercommunication techniques. By optimizing network protocols, minimizing data processing overhead, with optimized algorithms for data serialization and deserialization, reducing processing overhead and improving efficiency, while offering built-in capabilities like rate limiting and network traffic management for enhanced network efficiency and seamless data exchange to ensure faster response times, reduced communication delays, and enhanced overall performance in latency-sensitive applications.

## Table of Contents
- [Introduction](./#Introduction)
- [Quick Start](./#quick-start)
- [Features](./#Features)
- [Usage](./#Usage)
- [Contributing](./#Contributing)
- [License](./#License)


## Introduction
SLIC is designed to simplify client-server communication in Python applications. It enables the creation of resources and handles incoming client requests, allowing for efficient data transfer between the client and server. The library incorporates features such as rate limiting to prevent abuse and network traffic management for tracking and monitoring client connections.

## Quick Start
To quickly get started with SLIC, follow these steps:

1. Install SLIC library:
```sh
$ pip install slicpy
```
2. Import the necessary modules and classes:
```py
from slic import Slic, RateLimiter, Rate, NetworkTrafficMap
```

3. Create a server instance and define your resources:
```py
server = Slic()

def my_resource(payload):
    # Handle the client request and return a response
    return {'message': 'Hello, World!'}

server.create_resource(':my_resource', my_resource)

# Add more resources as needed

```

4. Start the server and listen for incoming connections:
```py
server.start('localhost', 9999)
```


5. Create a client instance and connect to the server:
```py
client = Slic()
client.link('localhost', 9999)

```

6. Send a request to the server and receive the response:
```py
response = client.get_resource(':my_resource', {})
print(response['message'])
```

For more detailed information on the SLIC library and its usage, refer to the Usage section.

## Features
SLIC provides the following key features:

- Resource Creation: Create and manage resources on the server for handling specific client requests.
- Request Handling: Handle incoming client requests and execute the associated resource logic.
- Upload Resources: Enable clients to upload files or data to the server.
- Rate Limiting: Apply rate limits to control the number of requests from a client within a given time frame.
Network Traffic Management: Track and manage client connections and their request counts.

## Usage
The SLIC library can be used to build client-server applications with ease. Below is a more detailed explanation of the library's usage and its main components.

### Resource Creation
To create a resource on the server, use the create_resource method. This method takes two parameters: the access path and the resource function.

Example:

```py
server.create_resource(':my_resource', my_resource_function)
```

### Request Handling
SLIC handles incoming client requests through the handle_conns method. This method is executed in a separate thread for each client connection.

Example:

```py
def handle_conns(conn, addr):
    # Handle the client connection and request here
    pass

    # Inside the Slic class
    thread = threading.Thread(target=handle_conns, args=(conn, addr))
    thread.start()
```
### Upload Resources
SLIC allows clients to upload files or data to the server by creating upload resources using the create_upload_resource method. This method takes two parameters: the access path and the storage location.

server.py
```py
from slic import Slic

# Create a SLIC server instance
server = Slic()

# Define an upload resource for handling file uploads
def handle_upload(payload):
    file_content = payload['file'].read()
    # Process the uploaded file content
    return {'success': True}

# Create an upload resource and assign it a unique access key
server.create_upload_resource(':upload', '/path/to/storage')

# Start the server on a specific host and port
server.start('localhost', 9999)

```

client.py
```py
from slic import Slic

# Create a SLIC client instance
client = Slic()

# Connect to the SLIC server
client.connect('localhost', 9999)

# Upload a file to the server
with open('path/to/file.txt', 'rb') as file:
    response = client.upload_resource(':upload', 'path/to/file.txt')

print(response)  # {'success': True}

# Close the client connection
client.close()
```

### Example Server

server.py
```py
from slic import Slic

# Create a SLIC server instance
server = Slic()

# Define your resources (functions to handle client requests)
def add(payload):
    return {'answer': payload['a'] + 1}

def login(payload):
    return {'login': True}

# Create resources and assign them unique access keys
server.create_resource(':add', add)
server.create_resource(':login', login)

# Start the server on a specific host and port
server.start('localhost', 9999)
```

### Example Client
To make requests to the SLIC server, you can use the SLIC client:
```py
from slic import Slic

# Create a SLIC client instance
client = Slic()

# Connect to the SLIC server
client.connect('localhost', 9999)

# Send a request to the server
response = client.get_resource(':add', {'a': 10})
print(response)  # {'answer': 11}

# Close the client connection
client.close()
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/teddyoweh/SLIC",
    "name": "slicpy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Teddy Oweh",
    "author_email": "teddyoweh@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ad/cf/dddc232d642db3bde81802a290bb55d6d50b526962b79fdab34cf2fdb07b/slicpy-0.0.9.tar.gz",
    "platform": null,
    "description": "# SLIC - (Swift Low-latency Intercommunication)\n\nSLIC (Swift Low-latency Intercommunication) simplifies client-server communication using tcp / p2p protocols while focusing on latency reduction through low-latency intercommunication techniques. By optimizing network protocols, minimizing data processing overhead, with optimized algorithms for data serialization and deserialization, reducing processing overhead and improving efficiency, while offering built-in capabilities like rate limiting and network traffic management for enhanced network efficiency and seamless data exchange to ensure faster response times, reduced communication delays, and enhanced overall performance in latency-sensitive applications.\n\n## Table of Contents\n- [Introduction](./#Introduction)\n- [Quick Start](./#quick-start)\n- [Features](./#Features)\n- [Usage](./#Usage)\n- [Contributing](./#Contributing)\n- [License](./#License)\n\n\n## Introduction\nSLIC is designed to simplify client-server communication in Python applications. It enables the creation of resources and handles incoming client requests, allowing for efficient data transfer between the client and server. The library incorporates features such as rate limiting to prevent abuse and network traffic management for tracking and monitoring client connections.\n\n## Quick Start\nTo quickly get started with SLIC, follow these steps:\n\n1. Install SLIC library:\n```sh\n$ pip install slicpy\n```\n2. Import the necessary modules and classes:\n```py\nfrom slic import Slic, RateLimiter, Rate, NetworkTrafficMap\n```\n\n3. Create a server instance and define your resources:\n```py\nserver = Slic()\n\ndef my_resource(payload):\n    # Handle the client request and return a response\n    return {'message': 'Hello, World!'}\n\nserver.create_resource(':my_resource', my_resource)\n\n# Add more resources as needed\n\n```\n\n4. Start the server and listen for incoming connections:\n```py\nserver.start('localhost', 9999)\n```\n\n\n5. Create a client instance and connect to the server:\n```py\nclient = Slic()\nclient.link('localhost', 9999)\n\n```\n\n6. Send a request to the server and receive the response:\n```py\nresponse = client.get_resource(':my_resource', {})\nprint(response['message'])\n```\n\nFor more detailed information on the SLIC library and its usage, refer to the Usage section.\n\n## Features\nSLIC provides the following key features:\n\n- Resource Creation: Create and manage resources on the server for handling specific client requests.\n- Request Handling: Handle incoming client requests and execute the associated resource logic.\n- Upload Resources: Enable clients to upload files or data to the server.\n- Rate Limiting: Apply rate limits to control the number of requests from a client within a given time frame.\nNetwork Traffic Management: Track and manage client connections and their request counts.\n\n## Usage\nThe SLIC library can be used to build client-server applications with ease. Below is a more detailed explanation of the library's usage and its main components.\n\n### Resource Creation\nTo create a resource on the server, use the create_resource method. This method takes two parameters: the access path and the resource function.\n\nExample:\n\n```py\nserver.create_resource(':my_resource', my_resource_function)\n```\n\n### Request Handling\nSLIC handles incoming client requests through the handle_conns method. This method is executed in a separate thread for each client connection.\n\nExample:\n\n```py\ndef handle_conns(conn, addr):\n    # Handle the client connection and request here\n    pass\n\n    # Inside the Slic class\n    thread = threading.Thread(target=handle_conns, args=(conn, addr))\n    thread.start()\n```\n### Upload Resources\nSLIC allows clients to upload files or data to the server by creating upload resources using the create_upload_resource method. This method takes two parameters: the access path and the storage location.\n\nserver.py\n```py\nfrom slic import Slic\n\n# Create a SLIC server instance\nserver = Slic()\n\n# Define an upload resource for handling file uploads\ndef handle_upload(payload):\n    file_content = payload['file'].read()\n    # Process the uploaded file content\n    return {'success': True}\n\n# Create an upload resource and assign it a unique access key\nserver.create_upload_resource(':upload', '/path/to/storage')\n\n# Start the server on a specific host and port\nserver.start('localhost', 9999)\n\n```\n\nclient.py\n```py\nfrom slic import Slic\n\n# Create a SLIC client instance\nclient = Slic()\n\n# Connect to the SLIC server\nclient.connect('localhost', 9999)\n\n# Upload a file to the server\nwith open('path/to/file.txt', 'rb') as file:\n    response = client.upload_resource(':upload', 'path/to/file.txt')\n\nprint(response)  # {'success': True}\n\n# Close the client connection\nclient.close()\n```\n\n### Example Server\n\nserver.py\n```py\nfrom slic import Slic\n\n# Create a SLIC server instance\nserver = Slic()\n\n# Define your resources (functions to handle client requests)\ndef add(payload):\n    return {'answer': payload['a'] + 1}\n\ndef login(payload):\n    return {'login': True}\n\n# Create resources and assign them unique access keys\nserver.create_resource(':add', add)\nserver.create_resource(':login', login)\n\n# Start the server on a specific host and port\nserver.start('localhost', 9999)\n```\n\n### Example Client\nTo make requests to the SLIC server, you can use the SLIC client:\n```py\nfrom slic import Slic\n\n# Create a SLIC client instance\nclient = Slic()\n\n# Connect to the SLIC server\nclient.connect('localhost', 9999)\n\n# Send a request to the server\nresponse = client.get_resource(':add', {'a': 10})\nprint(response)  # {'answer': 11}\n\n# Close the client connection\nclient.close()\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Swift Low-latency Intercommunication",
    "version": "0.0.9",
    "project_urls": {
        "Homepage": "https://github.com/teddyoweh/SLIC"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "adcfdddc232d642db3bde81802a290bb55d6d50b526962b79fdab34cf2fdb07b",
                "md5": "cb8fd9301cf625ae5cbf328be38d85a3",
                "sha256": "fdf6235a7c595850988e6317eddc4e2ba3914e6874f1938eee0f364d39108c94"
            },
            "downloads": -1,
            "filename": "slicpy-0.0.9.tar.gz",
            "has_sig": false,
            "md5_digest": "cb8fd9301cf625ae5cbf328be38d85a3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 10307,
            "upload_time": "2023-05-16T03:42:55",
            "upload_time_iso_8601": "2023-05-16T03:42:55.668527Z",
            "url": "https://files.pythonhosted.org/packages/ad/cf/dddc232d642db3bde81802a290bb55d6d50b526962b79fdab34cf2fdb07b/slicpy-0.0.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-16 03:42:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "teddyoweh",
    "github_project": "SLIC",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "slicpy"
}
        
Elapsed time: 0.17191s