All Projects → shogowada → scala-json-rpc

shogowada / scala-json-rpc

Licence: MIT License
Let your servers and clients communicate over function calls! JSON-RPC 2.0 library for Scala and Scala.js

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to scala-json-rpc

Rpc Codec
JSON-RPC 2.0 codec for Go net/rpc standard library
Stars: ✭ 87 (+128.95%)
Mutual labels:  json-rpc, rpc
Jsonrpc
The jsonrpc package helps implement of JSON-RPC 2.0
Stars: ✭ 143 (+276.32%)
Mutual labels:  json-rpc, rpc
Remote Function
Make function calls to remote hosts seamlessly
Stars: ✭ 95 (+150%)
Mutual labels:  json-rpc, rpc
Getty
a netty like asynchronous network I/O library based on tcp/udp/websocket; a bidirectional RPC framework based on JSON/Protobuf; a microservice framework based on zookeeper/etcd
Stars: ✭ 532 (+1300%)
Mutual labels:  json-rpc, rpc
Spooky
An HttpClient based Json RPC 2.0/XML-RPC client for .Net.
Stars: ✭ 16 (-57.89%)
Mutual labels:  json-rpc, rpc
Libjson Rpc Cpp
C++ framework for json-rpc (json remote procedure call)
Stars: ✭ 653 (+1618.42%)
Mutual labels:  json-rpc, rpc
Jsonrpcserver
Process JSON-RPC requests in Python
Stars: ✭ 126 (+231.58%)
Mutual labels:  json-rpc, rpc
Jrpc
JSON-RPC implementation in C++17
Stars: ✭ 113 (+197.37%)
Mutual labels:  json-rpc, rpc
Ether1
Official Go implementation of The Etho Protocol
Stars: ✭ 41 (+7.89%)
Mutual labels:  json-rpc, rpc
xmlrpcwsc-dotnet
XML-RPC Web Service Client C# implementation
Stars: ✭ 30 (-21.05%)
Mutual labels:  json-rpc, rpc
Vs Streamjsonrpc
The StreamJsonRpc library offers JSON-RPC 2.0 over any .NET Stream, WebSocket, or Pipe. With bonus support for request cancellation, client proxy generation, and more.
Stars: ✭ 421 (+1007.89%)
Mutual labels:  json-rpc, rpc
JsonRpc.Standard
An asynchronous .NET Standard library for JSON RPC client & server implementation.
Stars: ✭ 27 (-28.95%)
Mutual labels:  json-rpc, rpc
Joyrpc
high-performance, high-extensibility Java rpc framework.
Stars: ✭ 290 (+663.16%)
Mutual labels:  json-rpc, rpc
jsonrpcpp
C++ JSON-RPC 2.0 library
Stars: ✭ 97 (+155.26%)
Mutual labels:  json-rpc, rpc
aiohttp-rpc
A simple JSON-RPC for aiohttp
Stars: ✭ 22 (-42.11%)
Mutual labels:  json-rpc, rpc
Rpc
Simple RPC style APIs with generated clients & servers.
Stars: ✭ 192 (+405.26%)
Mutual labels:  json-rpc, rpc
coreipc
WCF-like service model API for communication over named pipes and TCP. .NET and node.js clients.
Stars: ✭ 22 (-42.11%)
Mutual labels:  json-rpc, rpc
server
Implement the JSON-RPC 2.0 server specification for @laravel.
Stars: ✭ 154 (+305.26%)
Mutual labels:  json-rpc, rpc
cli
Command Line Interface for @imqueue
Stars: ✭ 20 (-47.37%)
Mutual labels:  rpc
simpleRPC
Simple RPC implementation for Arduino.
Stars: ✭ 28 (-26.32%)
Mutual labels:  rpc

scala-json-rpc

⚠️ This project is not maintained anymore, and I'm looking for a kind person who can take it over from me.
If you can inherit this project, please send a pull request to this README.md linking to your project so that we can direct people to the new home.

master: Master Build Status

Let your servers and clients communicate over function calls!

scala-json-rpc is a Remote Procedure Call (RPC) library honorring JSON-RPC 2.0 spec.

JSON-RPC defines a specification of RPC in JSON format. This means that you can achieve RPC between your components as long as they are capable of

  • Serializing and deserializing JSON
  • Passing strings around
+--------+                          +--------+
|        | ---[request as JSON]---> |        |
| Client |                          | Server |
|        | <--[response as JSON]--- |        |
+--------+                          +--------+

Quick look

Shared between server and client

Using scala-json-rpc, your server and client can communicate over statically typed interfaces like below:

trait LoggerAPI {
  def log(message: String): Unit
}

case class Foo(id: String)

trait FooRepositoryAPI {
  def add(foo: Foo): Future[Unit]
  def remove(foo: Foo): Future[Unit]
  def getAll(): Future[Set[Foo]]
}

Server

class LoggerAPIImpl extends LoggerAPI {
  override def log(message: String): Unit = println(message)
}

class FooRepositoryAPIImpl extends FooRepositoryAPI {
  var foos: Set[Foo] = Set()

  override def add(foo: Foo): Future[Unit] = this.synchronized {
    foos = foos + foo
    Future() // Acknowledge
  }

  override def remove(foo: Foo): Future[Unit] = this.synchronized {
    foos = foos - foo
    Future() // Acknowledge
  }

  override def getAll(): Future[Set[Foo]] = Future {
    foos
  }
}

val jsonSerializer = // ...
val server = JSONRPCServer(jsonSerializer)
server.bindAPI[LoggerAPI](new LoggerAPIImpl)
server.bindAPI[FooRepositoryAPI](new FooRepositoryAPIImpl)

def onRequestJSONReceived(requestJSON: String): Unit = {
  server.receive(requestJSON).onComplete {
    case Success(Some(responseJSON: String)) => sendResponseJSONToClient(responseJSON)
    case _ =>
  }
}

Client

val jsonSerializer = // ...
val jsonSender = // ...
val client = JSONRPCClient(jsonSerializer, jsonSender)

val loggerAPI = client.createAPI[LoggerAPI]
val fooRepositoryAPI = client.createAPI[FooRepositoryAPI]

loggerAPI.log("Hello, World!")

fooRepositoryAPI.add(Foo("A"))
fooRepositoryAPI.add(Foo("B"))

fooRepositoryAPI.remove(Foo("A"))

fooRepositoryAPI.getAll().onComplete {
  case Success(foos: Set[Foo]) => println(s"Received all the foos: $foos")
  case _ =>
}

def onResponseJSONReceived(responseJSON: String): Unit = {
  client.receive(responseJSON)
}

Dependency

Platform SBT Scala Version Scala JS Version
JVM "io.github.shogowada" %% "scala-json-rpc" % "0.9.3" 2.12
JS "io.github.shogowada" %%% "scala-json-rpc" % "0.9.3" 2.12 0.6.17+

scala-json-rpc has no external dependency, so it should fit into any of your Scala JVM & JS applications.

Tutorials

Examples

TODOs

It should already serve you well as a RPC library, but it still does not fully support JSON-RPC spec yet. Here are list of known JSON-RPC features that's not supported yet.

  • Send/receive named parameter
    • Define custom parameter name
  • Send/receive custom JSON-RPC error
  • Define custom JSON-RPC request ID
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].