Skip to content

Commit cd930ce

Browse files
committed
added stencil code
1 parent d461534 commit cd930ce

File tree

5 files changed

+111
-0
lines changed

5 files changed

+111
-0
lines changed

codelabs/grpc-rust-getting-started/completed/client/client.rs

Whitespace-only changes.

codelabs/grpc-rust-getting-started/start_here/Cargo.toml

Whitespace-only changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use tonic::Request;
2+
3+
use routeguide::route_guide_client::RouteGuideClient;
4+
use routeguide::{Point};
5+
6+
pub mod routeguide {
7+
tonic::include_proto!("routeguide");
8+
}
9+
10+
#[tokio::main]
11+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
12+
///////////////////////////////////////////////////////////////////////////
13+
// Codelab Hint: Logic for your gRPC Client will be added here.
14+
//
15+
// Steps include:
16+
// - Create a connection to the gRPC server using RouteGuideClient::connect(...).
17+
// - Call service methods on the client to interact with the server.
18+
///////////////////////////////////////////////////////////////////////////
19+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2015 gRPC authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
option java_multiple_files = true;
18+
option java_package = "io.grpc.examples.routeguide";
19+
option java_outer_classname = "RouteGuideProto";
20+
21+
package routeguide;
22+
23+
// Interface exported by the server.
24+
service RouteGuide {
25+
/////////////////////////////////////////////////////////////////////////////
26+
// Codelab Hint: Define RPC methods here
27+
/////////////////////////////////////////////////////////////////////////////
28+
}
29+
30+
message Point {
31+
/////////////////////////////////////////////////////////////////////////////
32+
// Codelab Hint: Define RPC methods here
33+
/////////////////////////////////////////////////////////////////////////////
34+
}
35+
36+
// A feature names something at a given point.
37+
//
38+
// If a feature could not be named, the name is empty.
39+
message Feature {
40+
/////////////////////////////////////////////////////////////////////////////
41+
// Codelab Hint: Define RPC methods here
42+
/////////////////////////////////////////////////////////////////////////////
43+
}
44+
45+
46+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
use std::sync::Arc;
2+
3+
use tonic::transport::Server;
4+
use tonic::{Request, Response, Status};
5+
6+
use routeguide::route_guide_server::{RouteGuide, RouteGuideServer};
7+
use routeguide::{Feature, Point};
8+
9+
/// Brings generated code into scope.
10+
pub mod routeguide {
11+
tonic::include_proto!("routeguide");
12+
}
13+
mod data;
14+
15+
#[derive(Debug)]
16+
pub struct RouteGuideService {
17+
features: Arc<Vec<Feature>>,
18+
}
19+
20+
#[tonic::async_trait]
21+
impl RouteGuide for RouteGuideService {
22+
async fn get_feature(&self, request: Request<Point>) -> Result<Response<Feature>, Status> {
23+
///////////////////////////////////////////////////////////////////////////
24+
// Codelab Hint: Logic for GetFeature will be added here.
25+
//
26+
// Steps include:
27+
// - Loop through server's features to find the feature that matches the
28+
// point.
29+
// - Return the feature if found.
30+
// - Return an unnamed feature if no feature is found.
31+
///////////////////////////////////////////////////////////////////////////
32+
}
33+
}
34+
35+
#[tokio::main]
36+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
37+
///////////////////////////////////////////////////////////////////////////
38+
// Codelab Hint: Logic for starting up a gRPC Server will be added here.
39+
//
40+
// Steps include:
41+
// - Specify the port we want to use to listen for client requests using
42+
// - Create an instance of the gRPC server using RouteGuideServer::new().
43+
// - Register our service implementation with the server.
44+
///////////////////////////////////////////////////////////////////////////
45+
}
46+

0 commit comments

Comments
 (0)