mirror of
https://github.com/logos-storage/nim-json-rpc.git
synced 2026-01-09 17:13:11 +00:00
Rebrand asyncdispatch2 to chronos (#50)
This commit is contained in:
parent
1083b2972a
commit
53ed44dfa5
@ -332,7 +332,7 @@ The `call` procedure takes care of the basic format of the JSON to send to the s
|
||||
However you still need to provide `params` as a `JsonNode`, which must exactly match the parameters defined in the equivalent `rpc` definition.
|
||||
|
||||
```nim
|
||||
import json_rpc/[rpcclient, rpcserver], asyncdispatch2, json
|
||||
import json_rpc/[rpcclient, rpcserver], chronos, json
|
||||
|
||||
var
|
||||
server = newRpcSocketServer("localhost", Port(8545))
|
||||
|
||||
@ -9,7 +9,7 @@ skipDirs = @["tests"]
|
||||
requires "nim >= 0.17.3",
|
||||
"nimcrypto",
|
||||
"stint",
|
||||
"asyncdispatch2",
|
||||
"chronos",
|
||||
"httputils",
|
||||
"chronicles"
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import tables, json, macros
|
||||
import asyncdispatch2
|
||||
import chronos
|
||||
from strutils import toLowerAscii
|
||||
import jsonmarshal
|
||||
export asyncdispatch2
|
||||
export chronos
|
||||
|
||||
type
|
||||
ClientId* = int64
|
||||
@ -55,7 +55,7 @@ proc processMessage*[T: RpcClient](self: T, line: string) =
|
||||
if not self.awaiting.hasKey(id):
|
||||
raise newException(ValueError,
|
||||
"Cannot find message id \"" & node["id"].str & "\"")
|
||||
|
||||
|
||||
let version = checkGet(node, "jsonrpc", JString)
|
||||
if version != "2.0":
|
||||
self.awaiting[id].asyncRaise(ValueError,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import json, strutils, tables
|
||||
import chronicles, httputils, asyncdispatch2
|
||||
import chronicles, httputils, chronos
|
||||
import ../client
|
||||
|
||||
logScope:
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import ../client, asyncdispatch2, tables, json
|
||||
import ../client, chronos, tables, json
|
||||
|
||||
type
|
||||
RpcSocketClient* = ref object of RpcClient
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import
|
||||
json, tables, asyncdispatch2, jsonmarshal, strutils, macros,
|
||||
json, tables, chronos, jsonmarshal, strutils, macros,
|
||||
chronicles, options
|
||||
export asyncdispatch2, json, jsonmarshal
|
||||
export chronos, json, jsonmarshal
|
||||
|
||||
type
|
||||
RpcJsonError* = enum rjeInvalidJson, rjeVersionError, rjeNoMethod, rjeNoId, rjeNoParams
|
||||
@ -9,7 +9,7 @@ type
|
||||
|
||||
# Procedure signature accepted as an RPC call by server
|
||||
RpcProc* = proc(input: JsonNode): Future[JsonNode] {.gcsafe.}
|
||||
|
||||
|
||||
RpcProcError* = ref object of Exception
|
||||
code*: int
|
||||
data*: JsonNode
|
||||
@ -147,7 +147,7 @@ proc route*(router: RpcRouter, data: string): Future[string] {.async, gcsafe.} =
|
||||
# const error code and message
|
||||
errKind = jsonErrorMessages[errState.err]
|
||||
# pass on the actual error message
|
||||
fullMsg = errKind[1] & " " & errState[1]
|
||||
fullMsg = errKind[1] & " " & errState[1]
|
||||
res = wrapError(code = errKind[0], msg = fullMsg, id = id)
|
||||
# return error state as json
|
||||
result = $res & messageTerminator
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import json, tables, options, macros
|
||||
import asyncdispatch2, router, chronicles
|
||||
import chronos, router, chronicles
|
||||
import jsonmarshal
|
||||
|
||||
export asyncdispatch2, json, jsonmarshal, router, chronicles
|
||||
export chronos, json, jsonmarshal, router, chronicles
|
||||
|
||||
type
|
||||
RpcServer* = ref object of RootRef
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import json, strutils
|
||||
import chronicles, httputils, asyncdispatch2
|
||||
import chronicles, httputils, chronos
|
||||
import ../server
|
||||
|
||||
logScope:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user