[−][src]Crate qrpc_sdk
A toolkit for writing clients on the qrpc message bus. This bus
is the backbone of the qaul.net service
ecosystem. With it you can create applications (services) that
interact with libqaul
, and other services on the same message
broker.
These crate docs describe the API and basic usage. For an overview of the core concepts of this ecosystem, consult the contributors manual.
Additionally, you can access documentation of the internal
utilities by passing "--features internals
" to your cargo
invocation. These components are exposed via the API either way,
but only documented on demand to not clutter the main
documentation.
Using this sdk
In order to interact with a running qrpc-broker
instance your
service needs to register itself and it's capabilities.
First your service needs a place to save some state, composing
different parts of this sdk together to create an app. You create
a Service
and RpcSocket
and connect to the rpc-broker
socket. First you will have to call register(...)
on the
Service
, before any messages can be relayed to you.
use qrpc_sdk::{Service, RpcSocket, default_socket_path}; let serv = Service::new("com.example.myapp", 1, "A simple app"); let sockt = RpcSocket::new(default_socket_path())?; serv.register(sock)?; println!("Service registered! Hash ID: {}", serv.hash_id().unwrap());
Include the client-lib of the component you want to connect to,
and call establish_connection()
, privded by
ServiceConnector
. This will establish a connection with the
service to verify it's capability set. Your service will also
have to implement this mechanism to be usable by other services on
the RPC bus.
After that you can call functions on the public API type of the
component. You can get a copy of it via your service handle:
service.component("net.qaul.libqaul")
.
If you want to see a minimal example of the smallest functional
service, see the ping
crate.
Modules
builders | A set of message builder utilities |
errors | RPC related error handling |
io | An I/O abstraction module for the qrpc system |
rpc | RPC message types used by the qrpc-sdk |
types | qrpc message types |
Structs
PosixAddr | |
PosixSocket | |
RpcSocket | A qrpc connection wrapper |
Service | A service representation on the qrpc system |
Traits
ServiceConnector | An external service that can be connected to |
Functions
default_socket_path | Get the location the qrpc socket should be by default |