Skip to content

Commit

Permalink
converted to .liquid, add _service on naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
codeitlikemiley committed Dec 16, 2023
1 parent 8eb2e35 commit 4914074
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "{{crate_name}}"
name = "{{crate_name}}_service"
version = "0.1.0"
edition = "2021"
authors = ["{{authors}}"]
Expand Down
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# GRPC Service Generator

[![Build Template](https://github.com/codeitlikemiley/service_template/actions/workflows/build.yml/badge.svg)](https://github.com/codeitlikemiley/service_template/actions/workflows/build.yml)

## Requirements

Note: Install the following before you can use the template generator.
Expand All @@ -20,14 +21,12 @@ Note: Install the following before you can use the template generator.
```sh
workspace (root)
├── Cargo.toml
├── Carg.lock
├── README.md
├── backend
├── backend (server_template)
├── frontend (Use Dioxus Template)
├── frontend (dioxus_template)
└── services
└── services (service_template)
└── <service_name>
├── proto
│ └── <service_name>.proto
Expand Down Expand Up @@ -68,9 +67,7 @@ cargo generate --git codeitlikemiley/services_template --name <service_name>
🔧 Initializing a fresh Git repository
✨ Done! New project created /Users/uriah/Code/example


cd <service_name>

cd <workspace_root>
```

### Build , Testing and Documentation
Expand Down Expand Up @@ -129,7 +126,7 @@ use auth_service::auth_impl::AuthServiceImpl;
#[tokio::main] // Use the tokio runtime for async
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let addr = "[::1]:50051".parse()?;

// Create a new instance of your service implementation
let auth = AuthServiceImpl{};

Expand All @@ -147,15 +144,17 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
### Test your Service with GRPC Client

1. Run Server

```sh
cargo run -p server
```

2. Use `grpcurl` Client

Tp invoke the specific rpc method use the following command
To invoke the specific rpc method use the following command
```sh
grpcurl -plaintext -import-path ./services/auth/proto -proto auth.proto -d '{"name": "Uriah"}' '[::1]:50051' auth.AuthService.Login
cd <workspace>
grpcurl -plaintext -import-path ./services/auth/proto -proto auth.proto -d '{"name": "Tonic"}' '[::1]:50051' auth.AuthService.Login
```

output:
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "1.74.0"
components = [ "rustfmt", "clippy" ]
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{{crate_name}}::{{"{"}}{{crate_name}}_service_server::{{project-name | pascal_case}}Service, {{project-name | pascal_case}}Request, {{project-name | pascal_case}}Response};
use tonic::{Request, Response, Status};

#[derive(Default)]
pub struct {{project-name | pascal_case}}ServiceImpl {}

#[tonic::async_trait]
Expand Down

0 comments on commit 4914074

Please sign in to comment.