Serverless Functions with Gluon CloudLink and Fn Project

Johan Vos
Oracle Developers
Published in
3 min readOct 12, 2017
fnproject.io

Over the last year or so there has been a growing buzz around ‘serverless’ functionality, also known as ‘Functions as a Service’ (or FaaS). This often simply boils down to being able to execute code without going through the hassle of setting up and managing infrastructure (and does indeed still rely on servers!

In the case of mobile applications, serverless functions add a number of benefits:

  • The less code on the client, the lesser the chance of client-side issues — this reduces the need for deploying hot fixes to customers and end users.
  • Speaking of which — client code is hard to update — and it is more than just sending a new build up to the various app stores. Changes require internal review and acceptance testing, and only then deployment to the various app stores, which typically takes days. In case of hot fixes, this is often not acceptable.
  • Client code works with simple objects, where enterprise code often require more complex calls and flows, using more parameters and configurations. The code to convert the enterprise result into a simple client object can be executed as a Function on a remote server, rather than burdening the client and the network with the overhead.

For this reason, Gluon CloudLink supports remote functions. Up until today, Gluon CloudLink already enabled client apps to call into it to run a remote function, and it could then transparently call zero or more REST endpoints and zero or more Amazon AWS Lambda funcions.

At the JavaOne 2017 conference, Oracle announced the Fn Project, an open source serverless functions platform that runs anywhere and supports running functions in every programming language. One of the major benefits of the Fn Project is that functions can be deployed on any system, including your local development system. That makes it very easy for developers to have short write-test-debug cycles.

As of this week, Gluon CloudLink has support for Fn Functions. Customers can write and build their own Fn functions, push them to a Docker repository, and have them run inside Gluon CloudLink’s infrastructure on a self-hosted Fn platform, when a mobile application requests them.

We will create more samples and tutorials for this. Meanwhile, in a nutshell this is how it works:

  1. Download/Install the Fn Project. This allows you to create and test your function locally, before you push it to a docker repository.
  2. Write your Fn function. A list of examples can be found in the GitHub repository.
mkdir myfunction 
cd myfunction
fn init — name myfunction — runtime java
fn run
  1. Build and push your Fn function to a public docker repository, i.e. Docker Hub:
fn build
fn push --registry DOCKER_HUB_USERNAME
  1. Create a remote function in Gluon CloudLink referencing the image in the docker repository [See screenshot below]
  2. Test the remote function by clicking the Test button [See other screenshot below]
  3. Call the remote function from a Mobile Application

Originally posted on gluonhq.com

--

--

Johan Vos
Oracle Developers

Java developer, Java Champion, co-founder and CTO at Gluon, CTO at LodgON, Using JavaFX and Java EE, working on the Java Mobile Enterprise