Git Product home page Git Product logo

naiverpc's Introduction

NaiveRPC

NaiveRPC, Rutgers CS 552 Course Project

Introduction

Follwing is the organization of this repository:

.
├── LICENSE
├── NaiveRPC
│   ├── __init__.py
│   ├── client.py  # definition of Client class
│   ├── crypto.py  # crypto library*
│   ├── function.py  # definition of Function and FunctionPool classes
│   ├── server.py  # definition of Server, ThreadServer and ThreadPoolServer classes
│   └── utils.py  # utility functions and how server handle requests
├── README.md
└── test
    ├── client.py  # test client
    ├── samples.py  # sample functions ready to be used by test server
    └── server.py  # test server
  • The crypto library is not implemented by us, we borrowed it from this source

Environment

  • We develope with Python v3.7.1:260ec2c36a and tested on following environments:
[1] Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:11 PDT 2020; root:xnu-7195.50.7~2/RELEASE_X86_64

[2] Linux ubuntu 4.15.0-126-generic #129-Ubuntu SMP Mon Nov 23 18:53:38 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
  • We used following third-party python libraries:
[bayesian-optimization 1.2.0] pip3 install bayesian-optimization
https://pypi.org/project/bayesian-optimization/

[pycryptodomex 3.9.9] pip3 install pycryptodomex==3.9.7
https://pypi.org/project/pycryptodomex/

A Simple Test

# Change to test directory
$ cd test

# In one terminal, start the test server
# Notice that "python3" is required
$ python3 server.py --server=thread
# or
$ python3 server.py --server=threadpool

# Open another terminal, start the test client
# Notice that "python3" is required
$ python3 client.py

# You will see messages from both server and client side,
# as well as a well-recorded log in the same folder

# You can also try to run tests interactively

Tutorial

server side

from NaiveRPC import Function, FunctionPool, RegisterFunction
from NaiveRPC import ThreadServer, ThreadPoolServer

# Prepare your function(s) for RPC service
def f():
  return "A simple function"

# Register your function(s)
F = RegisterFunction(f, public=True, always_return=True)

# Create a FunctionPool
FP = FunctionPool("simple function pool")

# Add the Function to the FunctionPool
FP.add(F)

# Create a server, specify FunctionPool and password
server = ThreadServer("127.0.0.1", 1000, FunctionPool=FP, password="42")

# Start the server
server.start()

client side

from NaiveRPC import Client

# Create a client and connect
client = Client()
client.connect('127.0.0.1', 10000)

# Authentication
client.authenticate("42")

# Examine the basic information
client.print()

# Examine the detailed information
client.print_all()

# Execute a function
client.execute("f()")

# Close the client
client.close()

log

  • You should expect a well-formatted log which record the time of events, what are those events and where do they happened.

Presentations

Group members

Wenjie Qiu: [email protected]

Yunhao Shi: [email protected]

Sen Zhang: [email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.