Skip to content

bdbelevate/grpc-template

Repository files navigation

{% assign name = crate_name | remove: "_service" %}{% assign plural_name = name | append: "s" %}{% assign pascal = name | pascal_case %}

{{ pascal }} Service

Note

This is a project template using cargo generate. The idea is to create a new service from scratch using this as a template. This includes a sample model and embedded object model as well as a bunch of tests. It requires using the latest version of cargo generate. So to install that do:

cargo install --git https://github.com/ashleygwilliams/cargo-generate

Then to create a new project:

cargo generate --git https://github.com/bdbelevate/grpc-template

Answer the prompts and voila! you have a new project.

Note: It will rename things and remove the word "service". So if you want to create an Events service with types called Event. Then enter the name as "EventService". That will result in a crate named event-service and it will have a type of message called Event.

Install

Install the required node packages which are used for commit hooks, etc...

npm install

Download the required crates and build the protobuf rs files.

cargo build

Usage

Run the cargo generate above. Then go and edit (and/or rename) the proto/sample.proto. Keep in mind that if you rename it you will need to change the build.rs accordingly.

If you add fields, you'll likely need to change the api/items.rs to update the update_one command.

Getting Started

  • Install Rust
  • Run cargo run to build and run service

Install Garden

See garden.io

VSCode

Plugins

  • Better TOML
  • Native Debug
  • Rust
  • rust-analyzer

Bloom RPC

Testing the gRPC calls is best done via (BloomRPC)[https://github.com/uw-labs/bloomrpc]. More info on their site but easiest way to install it is via brew.

brew cask install bloomrpc

Once it's installed you can open the proto file to test the endpoints.

About

A small service template using gRPC and mongo.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages