DEV Community

Sergio Lima
Sergio Lima

Posted on

The New Hello World for faastRuby - The Serverless Platform for Ruby & Crystal - Part 1.

alt text

Hi folks! I want to share with you one of the most emerging technologies for Cloud Computing. I'm talking about "Functions as a Service" or FaaS. In this article I want you to explore with me an introductory solution. We will build a serverless application, step by step, using the faastRuby platform, and we will make the solution available in the cloud.

If you are not familiar with these terms, do not worry. I've described more about faastRuby, FaaS and Serverless in this article in Portuguese and here in English.

faastRuby is an incredible platform and allows us to work easily with serverless functions. The platform is intuitive and very similar to Heroku, where the server infrastructure is totally abstracted.

Click here https://www.faastruby.io to know more about faastRuby.

Introduction

The faastRuby platform was updated and there were improvements after version 0.5, so I decided to rewrite the Hello World tutorial.

Understanding the Platform

faastRuby is a Serverless Software Development Platform for Ruby and Crystal, made of two main components.

Main Components

  1. faastRuby Cloud - where you deploy your applications and functions to.
  2. faastRuby Local - an SDK that allows you to develop and test rich web applications and APIs in your machine and deploy your app as a set of distributed functions to the platform. Basically all you have to do is write code. No Ops required.

Basic Concepts: Account, Project, Function & Workspace

  1. Account - To get started with the faastRuby Cloud Platform, you'll have to create an account, which you'll use to login on the Platform. A faastRuby account belongs to a person or a company.
  2. Function - faastRuby apps are built with pure Ruby or Crystal functions. Functions are the unit of deployment of faastRuby apps. Each function is its own thing - they are independent from each other.
  3. Project - Project is where your application stays. Your project will have a main folder, subfolders, static files and functions.
  4. Workspace - Workspaces are isolated environments where you deploy your functions to. They are represented by a URL like https://projectName-environment-abs123.tor1.faast.cloud.

Breaking Down a Workspace URL

Example https://projectName-environment-abs123.tor1.faast.cloud.

  • projectName: Your faastRuby project's name.
  • environment: Stage is the default environment. You can choose another one like prod, dev, etc.
  • abs123: This's the project identifier, used to ensure your workspaces will have unique names. It shouldn't be changed.

What are we going to create?

Using the faastRuby resources, we're going to create two Ruby functions locally, test them, and deployed them to the cloud.

Tools

  • ruby 2.6.0
  • gem faastruby

Step by Step Function Creation

Installation

Create your own folder for faastRuby projects and enter into it. This is not mandatory. I prefer to use this kind of folder organization, this way, all projects made in faastRuby stay inside this folder.

$ mkdir faastruby
$ cd faastruby
Enter fullscreen mode Exit fullscreen mode

Perform this step only if you use the Ruby version manager, RVM:

$ faastruby/> rvm use ruby-2.6.0@faastruby --ruby-version --create
Enter fullscreen mode Exit fullscreen mode

Install the gem

If you do not have the gem installed, perform:

$ faastruby/> gem install faastruby
Enter fullscreen mode Exit fullscreen mode

If you already have faastruby gem installed, just upgrade it:

$ faastruby/> faastruby update
Enter fullscreen mode Exit fullscreen mode

To know if it worked, let's see the gem version. For me this is the current version: 0.5.23. Note that your version may be newer, as the platform is constantly being updated.

$ faastruby/> faastruby -v
0.5.23
Enter fullscreen mode Exit fullscreen mode

Signing up on faastRuby Platform

$ faastruby/> faastruby signup

Welcome to FaaStRuby! Please enter your email address:
Email: <<< you@your-email.com >>>

Enter fullscreen mode Exit fullscreen mode

After entering your email, you can enter with your password.

Now type in a password. 
It must contain 8 to 50 characters and have at least 
one uppercase letter, one lowercase letter, 
one number and one special character @ $ ! % * ? &
************
✔ Creating your account...
Enter fullscreen mode Exit fullscreen mode

You'll then receive an email with a token for verification. Copy and paste the token into the field indicated below.

You should have received an email with a confirmation token.
If you didn't receive an email:
- Make sure you sign up with the correct email address
- The system won't send an email if you account status is already 'confirmed'
Confirmation Token: <<< your token here >>>
Enter fullscreen mode Exit fullscreen mode

Finally, you'll be registered and logged into the platform.

✔ Confirming your account...
Login successful!
Enter fullscreen mode Exit fullscreen mode

When you need to login, use the following command:

$ faastruby/> faastruby login       
Email: you@your-email.com
Password: ***********
Login successful.
Enter fullscreen mode Exit fullscreen mode

And when you need to logout, you can use:

$ faastruby/> faastruby logout ## use --all to logout from all machines
Logout successful.
Enter fullscreen mode Exit fullscreen mode

This article continues on Part 2 where we'll build up a faastRuby project and deploy it to the cloud.

Top comments (0)