Giter VIP home page Giter VIP logo

hello-rust-actix's Introduction

"Hello World!" via Rust and Actix

This Glitch project is a proof of concept for using Glitch with Rust, and specifically using Rust's Actix web framework to run a simple "Hello World!" backend web application.

It turns out that Glitch and Rust aren't quite a match made in heaven: Glitch containers just don't quite have the "oomph" needed for a smooth compilation experience. Nonetheless, it works! (Mostly.)

Mostly? What Do You Mean That it Mostly Works?

Well, building everything from a cold start with no S3 cache will take about an hour. That's... pretty bad.

It's a lot better with an S3 cache present, though! Check out the project's hidden .infra/ directory (on GitHub here: https://github.com/karlmdavis/hello-rust-actix/tree/master/.infra), which has Ansible scripts to setup the caching infrastructure in AWS for you: basically just an S3 bucket that the Glitch app can read from and write to. Once you have that setup, open up the .env file in Glitch and set the AWS_S3_CACHE_BUCKET, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY variables. After that, the project's install & compile loops drop down to 4 minutes or so, even from a cold start (once you've built things at least once to populate your cache). Yay!

(I mean, it's still not great, but it's at least workable.)

There is one other niggle, though: the cargo/rustc compile cycle uses more than 500 MB of RAM (when there's no cache present). In debug mode, it does seem to eventually sneak past Glitch's process killer and succeed. But I can't reliably get a --release build of the project to succeed

:shrug: Oh well.

Project Structure

Glitch-Specific Stuff

The glitch.json file tells when and how to run the glitch/install.sh and glitch/start.sh scripts to power this application.

To keep the project clean and avoid Glitch's 200MB project size limit we do all of our Rust installation, compilation, etc. in the container's /tmp directory.

References that were useful:

Rust and Actix

The project's basic Rust skeleton was created, as follows:

$ cargo new --bin ./hello-rust-actix && mv ./hello-rust-actix/* ./ && rmdir hello-rust-actix
     Created binary (application) `./hello-rust-actix` project

From there, I just followed the basic instructions on https://doc.rust-lang.org/book/ch01-03-hello-cargo.html and https://actix.rs/docs/getting-started/.

License

This project is in the worldwide public domain. As stated in CONTRIBUTING:

This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the CC0 1.0 Universal public domain dedication.

All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.

hello-rust-actix's People

Contributors

karlmdavis avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.