Tutorial: Experience The Power Of Macrometa Query Workers
Macrometa Query Workers offer a powerful solution for developers aiming to reduce development time, streamline data management, and optimize query processing capabilities. In this blog, we will examine the essential aspects of Query Workers, highlighting their core features and the numerous benefits they bring to developers.
Understanding Macrometa Query Workers
Macrometa Query Workers consist of named, parameterized C8QL or SQL queries stored within the Global Data Network (GDN). Accessible through a dedicated REST endpoint, they offer a versatile and scalable approach to executing custom data processing tasks and queries at the network edge. Utilizing Query Workers enables developers to construct the back-end of their applications in mere minutes, rather than days.
Designed for easy set-up and configuration - at the edge
Macrometa Query Workers are designed with you, the developer, in mind. They offer a simple and straightforward experience, requiring minimal setup and configuration to get started. To create a new Query Worker, all you need to do is define a query that performs your desired task. From there, you can easily generate an API endpoint to call from your application.
One of the key benefits of Query Workers lies in their ability to run directly at the network edge. This feature significantly reduces latency times for your apps, enabling you to deliver near-instantaneous responses to user queries. Unlike traditional cloud-based data processing solutions, which can be slower and less responsive due to latency in data transmission between the edge and the cloud, Macrometa Query Workers ensure a seamless and efficient experience for you and your customers.
Creating and utilizing Macrometa Query Workers
Creating and updating Query Workers is a breeze with the Macrometa GDN web console, CLI, SDK, or by directly interacting with the REST API. Each Query Worker consists of specific query text and may include a parameter set (bind variables). You have the option to set default values for query parameters, making them optional during the execution of your Query Worker. Alternatively, you can require mandatory parameters for each run, with failure resulting in an error.
To illustrate, let's create data for an imaginary shop inventory using the Macrometa console. The dataset we intend to save is represented by the JSON below.
"color": "Grey One",
"name": "Adidas Ultraboost 21",
You will be adding a single data point to the inventory, as demonstrated in the image below.
The initial step involves logging in to the Macrometa platform. Once logged in, select the Query Worker tab to access the query editor. If utilizing a C8QL query to insert data, the query should appear exactly like this:
Enhancing the flexibility of queries, the @ symbol indicates that we're using a field as a parameter, which we refer to as a bind variable. To test the query, simply click the "Run Query" button. If the query performs as expected, you can save it and generate an API endpoint for use in your application. Creating an endpoint is as easy as clicking the "API Endpoint" button, and just like that, you've built the Create operation from the CRUD!
To view the newly added data, query the entire inventory using the following:
FOR data in shopInventory
This represents the Read operation from the CRUD framework. Converting this query into an API endpoint is a straightforward process, as illustrated in the image below.
Each new query worker has its own endpoint on Macrometa GDN. Query Workers are organized by GeoFabric, enabling developers to have different Query Workers for different geo-regions as well as for different fabrics within the same region.
Integration with Akamai EdgeWorkers
With Macrometa’s integration with Akamai EdgeWorkers, you can automatically compile the Macrometa Query Workers into a native Akamai EdgeWorker and automatically deploy it onto Akamai’s edge. Simply supply your Akamai credentials and with the click of a button, the API gets generated as an Akamai EdgeWorker and is automatically deployed to 1000s of Akamai edge PoPs that query and serve data from adjacent Macrometa regions on Linode. Check out the full video streaming app (like a Netflix or a Hulu) that runs on the Akamai edge and Linode leveraging Macrometa, Linode and Akamai EdgeWorkers to see it in action!
Get started with Query Workers today!
Macrometa Query Workers offer a versatile and scalable solution for performing custom data processing tasks and real-time queries. With a straightforward setup process that allows you to focus solely on crafting queries, deployment is effortlessly handled by the Macrometa GDN.
By leveraging the flexibility and scalability of Query Workers, developers can optimize their data management and query processing workflows and incorporate them into existing workflows and processes. This can help improve query performance and minimize latency, allowing developers to execute complex queries and computations on large datasets quickly and efficiently.