npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

paws-lambda-time-trigger

v1.0.2

Published

Implements sub-minute time trigger support to trigger AWS Lambda functions

Downloads

1,031

Readme

PAWS Lambda Time Trigger

This package makes it easy to trigger Lambda functions more often than once a minute - the default service to trigger Lambdas periodically, EventBridge rules, will only allow to define schedules down to a resolution of 1 minute.

Using the PAWS Lambda Time Trigger package, you can define schedules with a resolution down to 1 second.

The PAWS Lambda Time Trigger package will, on top of any resources you create, including the Lambda function to be triggered on a schedule, create:

  • An AWS Step Function running the sub-minute schedule you defined by waiting between invokes of your target Lambda
  • An EventBrige rule triggering the AWS step function based on the rest of the schedule you define as a CRON expression

If you specify a CRON schedule without the second field being set, or with it being set to 0, the TimeTrigger will just create a plain EventBridge rule with that schedule triggering your Lambda directly, without the AWS Step Function in between.

Basic usage

TypeScript / JavaScript

const timeTrigger = new TimeTrigger(this, 'time-trigger', {
  schedule: {
    cron: {
      second: '0-19/5,20-59/20', // Triggers at seconds 0, 5, 10, 15, 20 and 40 of every minute...
      hour: '9-17' // ... of every hour between 9 and 17 each day
    },
  },
});

yourLambdaFunction.addEventSource(timeTrigger);

Known limitations

Lambda execution time

As of now, the AWS Step Function does not take the time required to execute the scheduled Lambda into account. In other words: if you schedule your Lambda with a TimeTrigger to be executed every 10 seconds (second:'*/10'), but your scheduled Lambda takes 1 second to run, you will see the following behavior:

  • The AWS Step function will be triggered every minute (unless you specified another schedule)
  • The AWS Step function will run your Lambda on...
    • Second 0, taking 1 second to complete, then waiting 10 seconds
    • Second 11, taking 1 second to complete, then waiting 10 seconds
    • Second 22, taking 1 second to complete, then waiting 10 seconds
    • Second 33, taking 1 second to complete, then waiting 10 seconds
    • Second 44, taking 1 second to complete, then waiting 10 seconds
    • Second 55, taking 1 second to complete, then finishing