Skip to main content

Akamai EdgeWorker SDK Support

This page shows you how to use Akamai EdgeWorkers with Macrometa SDKs and API calls.

Create or Update EdgeWorker Metadata

The first step to working with EdgeWorkers is to create EdgeWorker metadata. You can see more about parameters of metadata object in Manage Integrations.

You can also check if there is existing metadata set up, update metadata, and delete metadata.

  • Step 1. Install the SDK.
  • Step 2. Create an instance of the jsC8.
  • Step 3. Access Function commands client.function.<function method>.
const jsc8 = require("jsc8");
client = new jsc8({
url: "https://play.paas.macrometa.io/",
apiKey: "xxxxxx",
fabricName: "_system",
});

async function main() {
const response = await client.function.createEdgeWorkerMetadata({
"akamai",
"<accessToken>",
"<baseUri>",
"<clientSecret>",
"<clientToken>",
"200",
"<groupId>",
"test-akamai-ew.test.io"
});
console.log(response);
}

main();

Deploy Query Worker to EdgeWorker

When metadata is set up, you can deploy a query worker to an EdgeWorker with deployQueryWorkerToEdgeWorker method or an API call.

const jsc8 = require("jsc8");
client = new jsc8({
url: "https://play.paas.macrometa.io/",
apiKey: "xxxxxx",
fabricName: "_system",
});

async function main() {
const response = await client.function.deployQueryWorkerToEdgeWorker(
"akamai",
"testSdkEv",
"testSdkEv",
"PRODUCTION",
);
console.log(response);
}

main();

Deploy Stream Worker to EdgeWorker

const jsc8 = require("jsc8");
client = new jsc8({
url: "https://play.paas.macrometa.io/",
apiKey: "xxxxxx",
fabricName: "_system",
});

async function main() {
const response = await client.function.deployStreamPublisherToEdgeWorker(
{
"akamai",
"testSdkEvStreamPublisher",
"testSdkEvStreamPublisher",
"testSdkKvStreamPublisher",
"PRODUCTION",
}
);
console.log(response);
}

main();

Deploy Stream Ad Hoc Query to EdgeWorker

const jsc8 = require("jsc8");
client = new jsc8({
url: "https://play.paas.macrometa.io/",
apiKey: "xxxxxx",
fabricName: "_system",
});

async function main() {
const response = await client.function.deployStreamAdhocQueryToEdgeWorker(
{
"akamai",
"testSdkEvStreamAdhoc",
"testSdkKvStreamAdhoc",
"PRODUCTION",
}
);
console.log(response);
}

main();

Invoke EdgeWorker

const jsc8 = require("jsc8");
client = new jsc8({
url: "https://play.paas.macrometa.io/",
apiKey: "xxxxxx",
fabricName: "_system",
});

async function main() {
const response = await client.function.invokeFunctionWorker(
"functionName"
);
console.log(response);
}

main();

View Deployed EdgeWorkers

You can check deployed EdgeWorkers with listFunctionWorkers method or an API call.

const jsc8 = require("jsc8");
client = new jsc8({
url: "https://play.paas.macrometa.io/",
apiKey: "xxxxxx",
fabricName: "_system",
});

async function main() {
const response = await client.function.listFunctionWorkers();
console.log(response);
}

main();

Get EdgeWorker Details

You can get all the information about deployed EdgeWorker with getFunctionWorkerInfo method or an API call:

const jsc8 = require("jsc8");
client = new jsc8({
url: "https://play.paas.macrometa.io/",
apiKey: "xxxxxx",
fabricName: "_system",
});

async function main() {
const response = await client.function.getFunctionWorkerInfo(
"functionName"
);
console.log(response);
}

main();