Say Hello to Fragments

By Anthony Kiplimo

Over the past couple of months, the Elarian team has been hard at work refining and updating the platform. We believe in building tools that we love and that you’ll love as well. Today, we’re excited to announce Fragments; a powerful deployment tool that allows developers to deploy functions and bring their apps closer to their users.

Where to find Fragments

Fragments are available today on both test and live environments on the Elarian dashboard; On the topmost tab just before settings.

How Fragments work

To create a Fragment, click on create fragment and select the options that work for you. On test environments, you only have access to the base fragment, however, on the live environments, you’ll have more fully fleshed out fragments that can support the scale you’re aiming for.

Here’s a quick video showing how a fragment is created:

You have access to metrics and logs in a simple, easy-to-use UI. A code editor is also available allowing you to focus on building your fragment.

Write your First Fragment

Once you’ve created your first Fragment, you need to write some code and run it. When you land on the code editor, there’s some pre-written code. This code serves as a connector to external applications that you may have.

The context parameter holds the data that’s sent from your HTTP endpoint. While the callback will allow you to return the data that you manipulate on the Fragment side to your endpoint as well.

In this case, we created a JavaScript fragment so we’ll create a simple connection to Elarian. Add this code just above the pre-written code. If you haven’t created your credentials yet, you can grab them from your dashboard:

const { Elarian } = require("elarian");
    let client;
    function start(){
      client = new Elarian({
        appId: "",
        orgId: "",
        apiKey: ""
      });
      client
        .on("error", (error) => console.error(error))
        .on("connected", () => console.log("App is connected..."))
        .connect();
    }
    start();
    ......

Once you have your code written and you’re happy with it, hit deploy latest then click start and watch the magic happen
You can view your logs on the logs tab and you should see:

App is running...

Summary

In this article, we got to know what Fragments are and what you can do with them. We hope you have fun with it as much as we do.


We’re working hard to continue to polish the developer experience on the platform. Your feedback and suggestions are what keep us going. We hope you’ll enjoy using Fragments as much as we loved building it out.

To give feedback or just chat with the team join our Slack channel. Our events are always available on our Elarian Community site. To learn more about how to build with Elarian, check out these articles:

  1. Intro to Elarian: https://elarian.com/blog/introducing-the-elarian-framework
  2. Building a Simple Customer Service Bot on Elarian: https://elarian.hashnode.dev/build-a-simple-customer-service-chatbot-with-elarian-ep-1

Ready to get started ?

Copyright Elarian 2021