Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added separate rpc module, cleanup handling
- Loading branch information
1 parent
eb59fb5
commit 9ecb639
Showing
4 changed files
with
99 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use capnp; | ||
use capnp::capability::Promise; | ||
use microservice_capnp::microservice; | ||
|
||
/// The main RPC implementation structure | ||
pub struct Rpc; | ||
|
||
impl microservice::Server for Rpc { | ||
fn hello(&mut self, | ||
params: microservice::HelloParams, | ||
mut results: microservice::HelloResults) | ||
-> Promise<(), capnp::Error> { | ||
// Get the request | ||
let request = pry!(pry!(params.get()).get_request()); | ||
info!("Got request: {}", request); | ||
|
||
// Create the response | ||
let response: String = request.chars().rev().collect(); | ||
results.get().set_response(&response); | ||
info!("Returned reponse: {}", response); | ||
|
||
// Finish the future | ||
Promise::ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters