tynukrpc 1.2.0
An RPC library
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
rpc
An rpc library aimed to be protocol agnostic. It's based on automatic interface implementation.
It currently support:
It use vibed as HTTP and TCP driver.
It also use vibe.data.json for json serialization.
Quick start with dub
"dependencies": {
"rpc": "*"
}
Basic usage
An example showing how to fetch the last Ethereum block number using the rpc api.
import std.stdio;
import rpc.protocol.json;
interface IEthereumApi
{
string eth_blockNumber();
}
void main()
{
enum EthNode = "https://eth-mainnet.alchemyapi.io/jsonrpc/-vPGIFwUyjlMRF9beTLXiGQUK6Nf3k8z";
auto eth = new HttpJsonRpcAutoClient!IEthereumApi(EthNode);
writeln(eth.eth_blockNumber());
}
The server for the above example could be implemented like this:
import rpc.protocol.json;
interface IEthereumApi
{
string eth_blockNumber();
}
class EthereumServer : IEthereumApi
{
override string eth_blockNumber()
{
return "42";
}
}
void main()
{
import vibe.http.router;
enum EthNode = "https://eth-mainnet.alchemyapi.io/jsonrpc/-vPGIFwUyjlMRF9beTLXiGQUK6Nf3k8z";
auto eth = new HttpJsonRpcAutoClient!IEthereumApi(EthNode);
writeln(eth.eth_blockNumber());
auto router = new URLRouter();
auto server = new HttpJsonRpcServer!int(router, "/my_endpoint");
server.registerInterface!IEthereumApi(new EthereumServer());
listenHTTP("127.0.0.1:8080", router);
}
You can browse the examples
folder for more information.
- Registered by Volodymyr Drozd
- 1.2.0 released 2 years ago
- Tynukua/d-rpc-forked
- MIT
- Authors:
- Dependencies:
- vibe-d:data, vibe-d:utils, vibe-core, autointf, vibe-d:http
- Versions:
-
1.2.0 2022-Feb-08 ~master 2022-Feb-08 - Download Stats:
-
-
0 downloads today
-
4 downloads this week
-
48 downloads this month
-
333 downloads total
-
- Score:
- 1.2
- Short URL:
- tynukrpc.dub.pm