/usr/lib/swipl/library/ext/json/json_rpc_client.pl
All Application Manual Name SummaryHelp

  • ext
    • json
      • json.pl -- Reading and writing JSON serialization
      • json_grammar.pl
      • json_rpc_server.pl
      • json_schema.pl -- JSON Schema reader and validator
      • json_rpc_common.pl
      • json_rpc_client.pl -- JSON RPC client
        • json_call/4
        • json_notify/3
        • json_batch/5
        • json_full_duplex/2
      • json_convert.pl -- Convert between JSON terms and Prolog application terms
 json_call(+Stream, +Goal, -Result, +Options) is det
Run Goal on a JSON RPC service identified by Stream and wait for Result. This predicate may be called from multiple threads. As replies come in in arbitrary order, this predicate starts a thread the reads the replies from Stream and informs the calling thread using a Prolog message queue.

If Stream is closed this library terminates the thread and related message queue.

Options are passed to json_write_dict/3 and thread_get_message/3. Additional options:

async(:Closure)
Do not wait for the request to complete. Instead, call call(Closure, Data) from the client reading thread when the request is completed. If Closure is true, ignore the reply. As we cannot inject errors as exceptions in the calling thread, possible errors are printed.
thread_alias(+Atom)
Alias name to use for the thread that deals with incomming replies and requests. Defaults to json_rpc_client:<N>, where N is a unique number.
Arguments:
Goal- is a callable term. The functor name is the method. If there is a single argument that is a dict, we invoke a JSON-RPC method using named arguments. If there is a single argument that is a list, use the elements of the list as positional arguments. If there are zero or more than one arguments use these as positional arguments. Examples:
TermMethodTypeJSON (params)

f(#{a:1,b:2})fnamed{"a":1, "b":2}
f(["a", 42])fpositional["a", 42]
f([#{"a":1}])fpositional[{"a":1}]
f()fpositional[]
f("a", 42)fpositional["a", 42]

Options processed: