Skip to main content

A simple rpc implementation

Project description

RPC

A simple implementation of RPC (Remote Procedural Call) in python.

Examples:

#server implementation
from rpc import Server

server = Server("localhost", 3000)

@server.register("add")
def add(num1, num2):
    return num1 + num2

@server.register("concat")
def concat(str1, str2):
    return str1 + str2

@server.register("uppercase")
def uppercase(string):
    return string.upper()

server.run()
#client implementation
from rpc import Client

client = Client("localhost", 3000)
client.connect()

print(client.execute("/"))
#prints: ["add", "concat", "uppercase"]

print(client.execute("add", 1, 2))
#prints: 3

print(client.execute("concat", "a", "b"))
#prints: ab

print(client.execute("uppercase", "example"))
#prints: EXAMPLE

client.close()
#closes the socket connection

Links:

Github

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

rpc-Ariam27-0.1.0.tar.gz (3.4 kB view hashes)

Uploaded Source

Built Distribution

rpc_Ariam27-0.1.0-py3-none-any.whl (4.1 kB view hashes)

Uploaded Python 3

Supported by

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