PandaEdge
Edge Functions User Guide
Edge Functions allow you to run custom code at the edge of the network, closer to your users for faster response times. This guide will help you understand how to create, deploy, and manage your edge functions effectively.
Table of Contents
Creating a Function
Using the UI
Navigate to the Edge Functions section in your dashboard
Click the "Create Function" button
Fill in the basic information:
Function Name: Choose a unique name (4-12 characters, lowercase letters, numbers, and hyphens only)
Runtime: Select your preferred programming language and version
Write your code or upload a zip file containing your function files
Configure memory, timeout, and environment variables
Click "Deploy" to create your function
Function Naming
Names must be 4-12 characters long
Only lowercase letters, numbers, and hyphens are allowed
A random 6-character suffix will be added to your function name during deployment
Supported Runtimes
Our platform supports multiple programming languages:
Node.js
14, 16, 18, 20
index.js
Python
3, 3.9
main.py
Java
8
Main.java
Swift
5.1
main.swift
PHP
7.4
index.php
Ruby
2.5
main.rb
Go
1.15
main.go
Rust
1.54
main.rs
.NET
3.1
Main.cs
Ballerina
0.990
main.bal
Function Structure
Each function must have a main handler that processes incoming requests. The structure varies slightly depending on the programming language.
Node.js Example
Python Example
Environment Variables & Parameters
Setting Environment Variables
You can set environment variables in two ways:
Through the UI: When creating or editing a function, use the Environment Variables section
During deployment: Add them to your request when using the API
Environment variables are passed to your function through the params object.
Using Parameters
Parameters are passed to your function through the params object. There are multiple ways to pass parameters:
Query parameters: These are automatically included in the
paramsobjectJSON body: For POST requests, the JSON body is merged into the
paramsobjectEnvironment variables: All environment variables are included in the
paramsobject
Example: Accessing Parameters
Function Limits
Our platform enforces the following limits for edge functions:
Memory
256 MB
128 MB
1024 MB
Timeout
30 seconds
1 second
300 seconds
Package Size
-
-
10 MB
Concurrent Executions
1
-
-
Log Size
-
-
10 MB
Deploying Functions
Using the UI
Complete the function creation form
Click "Deploy" to create and activate your function
Function URL
After deployment, your function will be accessible at:
Testing Functions
Using the UI
Navigate to your function's details page
Go to the "Testing" tab
Enter test parameters in JSON format
Click "Test Function" to see the result
Using cURL
You can test your function using cURL:
Monitoring & Logs
Viewing Logs
Navigate to your function's details page
Go to the "Logs" tab to see execution logs
Use
console.log()(Node.js) orprint()(Python) to add custom log entries
Monitoring Metrics
The "Monitoring" tab provides metrics such as:
Invocation count
Error rate
Execution duration
Memory usage
Examples
Example 1: Simple API Response
Example 2: Using Environment Variables for Authentication
Example 3: Processing Form Data (Node.js)
Example 4: Handling Different HTTP Methods
Example 5: External API Integration (Python)
Example 6: Accessing OpenWhisk System Information
Your function has access to special parameters that provide information about the OpenWhisk environment:
Troubleshooting
Common Issues
Function Returns 502 Bad Gateway
Ensure your function returns a proper response object
Check your function logs for errors
Verify your function isn't timing out
Environment Variables Not Working
Make sure they are correctly set in the UI
Verify you're accessing them via the
paramsobject
Function Takes Too Long to Execute
Check if your function is making slow external API calls
Consider increasing the memory allocation
Optimize your code for better performance
Getting Help
If you continue to experience issues, please contact our support team with:
Your function name
Any error messages
Steps to reproduce the issue
Relevant logs
For more information or technical support, please contact our support team at [email protected]
Last updated