Skip to main content

Simple JSON-RPC service without transport layer

Project description

JSONRPCBase

https://ci.appveyor.com/api/projects/status/mgn5i4m1wx2nu70y?svg=true https://circleci.com/gh/level12/jsonrpcbase.svg?style=shield https://codecov.io/gh/level12/jsonrpcbase/branch/master/graph/badge.svg

Intro

Simple JSON-RPC service without transport layer

This library is intended as an auxiliary library for easy an implementation of JSON-RPC services with Unix/TCP socket like transport protocols that do not have complex special requirements. You need to utilize some suitable transport protocol with this library to actually provide a working JSON-RPC service.

Features

  • Easy to use, small size, well tested.

  • Supports JSON-RPC v2.0. Compatible with v1.x style calls with the exception of v1.0 class-hinting.

  • Optional argument type validation that significantly eases development of jsonrpc method_data.

Example

Example usage:

import jsonrpcbase

chat_service = jsonrpcbase.JSONRPCService()

def login(username, password, timelimit=0):
    (...)
    return True

def receive_message(**kwargs):
    (...)
    return chat_message

def send_message(msg):
    (...)

if __name__ == '__main__':

    # Adds the method login to the service as a 'login'.
    chat_service.add(login, types=[basestring, basestring, int])

    # Adds the method receive_message to the service as a 'recv_msg'.
    chat_service.add(receive_message, name='recv_msg', types={"msg": basestring, "id": int})

    # Adds the method send_message as a 'send_msg' to the service.
    chat_service.add(send_message, 'send_msg')

    (...)

    # Receive a JSON-RPC call.
    jsonmsg = my_socket.recv()

    # Process the JSON-RPC call.
    result = chat_service.call(jsonmsg)

    # Send back results.
    my_socket.send(result)

Questions & Comments

Please visit: http://groups.google.com/group/blazelibs

Current Status

Seems stable, but hasn’t been widely used to my knowledge.

The development version is installable with easy_install JSONRPCBase==dev.

Credits

This project was originally developed by:

Juhani Åhman http://bitbucket.org/fuzzybyte/jsonrpcbase/src

Changelog

0.2.0 released 2016-11-30

  • add Python 3 support (3.4 and 3.5)

  • set up continuous integration testing on CircleCI and AppVeyor

  • test coverage is on CodeCov

0.1.2 released 2012-03-08

  • fixed argument validation logic when using instance methods and no arguments

    (mlewellyn)

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

JSONRPCBase-0.2.0.tar.gz (7.4 kB view details)

Uploaded Source

File details

Details for the file JSONRPCBase-0.2.0.tar.gz.

File metadata

  • Download URL: JSONRPCBase-0.2.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for JSONRPCBase-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7ea67fc1a7c87756e9a876e18a342e431e80d0ef3ba867dfd6f3fac5bf3fcc0d
MD5 96059e46b8e1e8d09aae08fa8024e523
BLAKE2b-256 5c73ef26d23bc5ea384970da9dcd2a962ec84cf834922d94df85ab7c45e7a38e

See more details on using hashes here.

Provenance

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