Awtomate your 🦀 microservices with awto

Related tags

Utilities awto
Overview

awto

Awtomate your 🦀 microservices with awto

crate

What is awto?

Awto treats your rust project as the source of truth for microservices, and generates database tables and protobufs based on your schema and service.

Database Generation

  • Database tables are generated from your Rust structs
  • Changes to your structs are detected and will modify the table schema accordingly

Protobuf Generation

  • Generate protobuf schemas from your models
  • Compile a protobuf server from your app's service

Concepts

With awto, you create a Cargo workspace for each microservice. Under your workspace, you create two libs: schema and service

Schema

The schema lib's purpose is to define your microservice models which will be used to generate database tables.

// schema/src/lib.rs

register_schemas!(Product);

#[derive(Model)]
pub struct Product {
    pub id: Uuid,
    pub created_at: DateTime<FixedOffset>,
    pub updated_at: DateTime<FixedOffset>,
    pub name: String,
    #[awto(max_len = 120)]
    pub description: Option<String>,
    #[awto(default = 0)]
    pub price: i64,
}

See example schema in examples/ecom.

Service

The service lib is where you write your business logic. This business logic can later be used to create a protobuf API (and in the future a graphql API).

// service/src/lib.rs

register_services!(ProductService);

pub struct ProductService {
    pub conn: DatabaseConnection,
}

#[protobuf_service]
impl ProductService {
    pub async fn find_by_id(&self, request: ProductId) -> Result
    {
        
   let product 
   = product
   ::Entity
   ::
   find_by_id(request.id)
            .
   one(
   &
   self.conn)
            .
   await
            .
   map_err(
   |err
   | Status
   ::
   internal(err.
   to_string()))?
            .
   ok_or_else(
   || Status
   ::
   not_found(
   "product not found"))?;

        
   Ok(product.
   into())
    }
}
  

See example service in examples/ecom.

Cargo workspace

Your schema and service libs should be under a cargo workspace.

# root Cargo.toml
[workspace]
members = ["schema", "service"]

See example project in examples/ecom.

Awto CLI

Awto provides a cli for generating additional libraries with the awto compile command. Currently the available libraries are:

  • database - based on SeaORM, provides a database library for use in your service
  • protobuf - based on tonic, provides a protobuf server library

Install

The cli can be installed with:

cargo install awto-cli

This will provide a binary called awto.

Check installation with awto --help.

Compile library

To compile a library, you can run:

awto compile <output>

The available outputs currently are:

  • database - syncs your database with your schema and generates a lib for performing operations with the database via SeaORM.
  • protobuf - generates a protobuf file and lib which can be used as a protobuf server & client via tonic.

Roadmap

Awto is still in alpha stages and is made mostly as an experiment at this point. If it gets some attention, serious effort will be put into it to make it a meaningful tool for the Rust community.

Contributing

Whether you want to share ideas, bugs, suggestions, or other, your contributions to this project are welcomed 🤌

License

By contributing, you agree that your contributions will be licensed under this repository's MIT or Apache-2.0 License.

You might also like...
miette is a diagnostic library for Rust. It includes a series of traits/protocols that allow you to hook into its error reporting facilities, and even write your own error reports!
miette is a diagnostic library for Rust. It includes a series of traits/protocols that allow you to hook into its error reporting facilities, and even write your own error reports!

miette is a diagnostic library for Rust. It includes a series of traits/protocols that allow you to hook into its error reporting facilities, and even write your own error reports!

Clean up the lines of files in your code repository

lineman Clean up the lines of files in your code repository NOTE: While lineman does have tests in place to ensure it operates in a specific way, I st

A service for helping your cat find other cats
A service for helping your cat find other cats

Check back later! Discord Self-hosting This is an open-source service! Feel free to host you own private instances. All we ask is you credit us and li

Helps positioning your tauri windows.

Tauri plugin positioner A plugin for tauri that helps positioning you windows at well known locations. Install Rust [dependencies] tauri-plugin-positi

Ditch your status bar for some snazzy desktop notifications.
Ditch your status bar for some snazzy desktop notifications.

citron Ditch your panel for some snazzy desktop notifications. citron is: a non-intrusive alternative to status bars. on-demand, i.e. does not run in

Licensebat - 🔐⛵ Effortless dependency compliance with your license policies

Licensebat All docs here are temporary. Thougths For the moment, it seems it makes sense to have all the collectors sharing the same trait. That doesn

Dr-dotnet - 🩺 One-click diagnosis of your dotnet applications. Works both locally or remotely as a web service

Dr-dotnet - 🩺 One-click diagnosis of your dotnet applications. Works both locally or remotely as a web service. Based on the lowest level dotnet profiling APIs and using the rust language 🦀 for a minimal runtime penalty.

*looks in your general direction*

mirror the distributed mirroring service you never wanted (but i delivered to you anyway) what a distributed channel mirroring service for multiple se

Tagref helps you maintain cross-references in your code.

Tagref helps you maintain cross-references in your code. You can use it to help keep things in sync, document assumptions, manage invariants, etc. Airbnb uses it for their front-end monorepo. You should use it too!

Comments
  • BUG: install awto-cli

    BUG: install awto-cli

    I'm just try install using cargo install awto-cli and during compile time I got a lot errors:

    • cannot find clap
    • cannot derive macro Parser
    • no function or associated item named into_app
    opened by marioidival 1
Owner
Awto
Awtomate your 🦀 microservices with awto
Awto
Simple timer for your terminal

consoleTimer Simple timer that allows you to initiate countdown from N seconds. Usage: consoletimer [time in seconds] consoletimer [time in minutes]m

Arthur 20 Apr 4, 2022
🌲 Open the current remote repository in your browser

gitweb Some of the flags and options are subject to change in the future. Ideas are welcome. Ideas are bulletproof (V). gitweb is a command line inter

Yoann Fleury 26 Dec 17, 2022
Gather metadata about your S3 buckets

S3 Meta This tool has been migrated into s3-utils, please use that crate for future updates. A simple tool to gather data about an S3 bucket (or subse

Isaac Whitfield 48 Dec 27, 2022
A nifty commandline tool to manage your workstation.

workstation It's a nifty commandline rust tool to make you sit slightly away from your screen by blacking out the screen if you come too close and loc

Amar Lakshya (desi_tux) 16 May 6, 2022
Keep your dependencies up-to-date

Deps.rs - Dependency status at a glance Deps.rs is a service that shows you at a glance if any of your dependencies are out of date or insecure. This

deps.rs 369 Jan 5, 2023
Cross-platform bookmarks manager for your shell

shellmark: bookmark manager for shell THIS IS AN EARLY ALPHA. It works for me, but requires better UX and more polish. shellmark is a cross-platform b

Artem Pyanykh 25 Nov 10, 2022
Czkawka is a simple, fast and easy to use app to remove unnecessary files from your computer.

Multi functional app to find duplicates, empty folders, similar images etc.

Rafał Mikrut 9.2k Jan 4, 2023
🦸‍♂️ Recast migrates your old extensions to AndroidX, making them compatible with the latest version of Kodular.

Recast Recast helps make your old extensions compatible with Kodular Creator version 1.5.0 or above. Prerequisites To use Recast, you need to have Jav

Shreyash Saitwal 13 Dec 28, 2022
Add nice user-facing diagnostics to your errors without being weird about it.

thisdiagnostic is a Rust library for adding rich diagnostic metadata to errors, for some really fancy and customizable error reporting!

Kat Marchán 14 Feb 2, 2022
Combine internet connections, increase your download speed

dispatch A SOCKS proxy that balances traffic between network interfaces. Should work on macOS, Windows, and Linux. Only tested on macOS for now. This

Alexandre Kirszenberg 90 Jan 7, 2023