Skip to content

johnelamont/sleep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sleep Function

A serverless REST API endpoint built with Zoho Catalyst that sleeps for a specified duration.

Overview

This is a lightweight function-as-a-service (FaaS) application demonstrating a basic HTTP endpoint on the Zoho Catalyst platform. It accepts either a seconds or milliseconds parameter and pauses execution for that duration before returning a response.

Project Structure

sleep/
├── .catalystrc                 # Local Catalyst configuration
├── catalyst.json               # Project manifest
└── functions/
    └── sleep_function/
        ├── index.py            # Handler implementation
        ├── catalyst-config.json # Function configuration
        └── requirements.txt    # Python dependencies

Technology Stack

  • Platform: Zoho Catalyst
  • Runtime: Python 3.9
  • Function Type: BasicIO (HTTP request/response handler)

API Reference

Sleep Endpoint

Endpoint: /sleep_function

Method: GET

Parameters:

Parameter Type Required Description
seconds number * Number of seconds to sleep (0-30)
milliseconds number * Number of milliseconds to sleep (0-30000)

* Provide one or the other, not both. Do NOT exceed 30 seconds or 30000 milliseconds

Example Requests:

# Using seconds
curl "https://sleep-900403292.development/sleep_function?seconds=5"

# Using milliseconds
curl "https://sleep-900403292.development/sleep_function?milliseconds=500"

Success Response:

{
  "success": true,
  "message": "Slept for 5 seconds",
  "slept_for": 5,
  "unit": "seconds"
}
{
  "success": true,
  "message": "Slept for 500 milliseconds",
  "slept_for": 500,
  "unit": "milliseconds"
}

Error Responses:

Missing parameter:

{"error": "seconds or milliseconds parameter is required", "usage": "?seconds=NUMBER or ?milliseconds=NUMBER"}

Both parameters provided:

{"error": "Provide either seconds or milliseconds, not both", "usage": "?seconds=NUMBER or ?milliseconds=NUMBER"}

Invalid type:

{"error": "Invalid seconds parameter. Must be a number.", "provided": "abc"}

Out of range:

{"error": "Maximum sleep time is 30 seconds", "provided": 60}

Negative value:

{"error": "Seconds must be non-negative", "provided": -5}

Dependencies

  • zcatalyst-sdk==1.0.3 - Zoho Catalyst Python SDK

Installation

Prerequisites

  • Python 3.9+
  • Zoho Catalyst CLI

Local Setup

pip install -r functions/sleep_function/requirements.txt

Deploy to Catalyst

catalyst deploy

Configuration

The function is configured via catalyst-config.json:

  • Runtime: Python 3.9
  • Type: BasicIO
  • Entry Point: index.py

License

[Specify your license]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages