Functions as a Service — A simple use case

Backend Aug 14, 2020

Personally, I’m not the kind of a techie who uses a tech just for the sake of it. For me, the choice of a particular tool/technology/pattern must have a reason behind it, So, although I’ve been curious about Functions as a Service (Faas) for a while now, it was today when I finally got a chance to try it out.


The Problem

At my current organization, Onna, we use Clubhouse for our Agile Development process. Although they have an official Slack App to connect Clubhouse to our Slack workspace, there was one important workflow that the app didn’t cover:

“When a Story gets moved to the state For Review, A message with the story details should be sent on a relevant slack channel”

The Approach

Pretty straightforward. Clubhouse has a Webhooks API that gets triggered every time a Story has some updates. So, basically what we need to do is —

  • Catch the Webhook Trigger
  • Get details about the Event
  • If the event is “Moved to For Review Status”
  • Build the message and send it to Slack using Slack API

The Solution

While thinking about the algorithm, I realized I could get what I needed by writing a few lines of code. It didn’t need to save state, and could be a simple golang function that would wrap it all up and deploy it with Google Cloud functions!

But why would I want to write a cheap and quick golang function and deploy it as a service? Because apart from being easy to write, deploying as FaaS saves me from all of the following —

  • Setting up a Machine (Compute Instance/Docker/whatever)
  • Setup Logging
  • All the faff setting up networking — Routing, Load Balancing, etc.

All I had to do was write a single file golang program, upload it, click a couple of buttons and voila! Google Cloud Functions provides me with an HTTPs endpoint that I can use to attend to the Webhook Triggers from Clubhouse.


TLDR; Conclusion

In my opinion, for building simple tooling, Functions as a Service is an excellent option. You try to keep your code simple, the functions can be triggered using Http, Pub/Sub etc and above all deploying a FaaS is extremely easy and quick compared to if I had to deploy the same code on containers/servers.


Original Post - https://medium.com/@pavelito/functions-as-a-service-a-simple-use-case-e66f90767f07

Tags

Pavel Pratyush

Engineering Manager at Onna