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

archimedes-jobs

v1.0.4

Published

Archimedes is an abstract distributed job engine on AWS.

Downloads

23

Readme

Archimedes

Archimedes is an abstract distributed job engine on AWS.

SDK use

Import SDK

const Archimedes = require("archimedes-jobs")("<NAME_OF_LAMBDA_FUNCTION>");
import archimedes from "archimedes-jobs";
const Archimedes = archimedes("<NAME_OF_LAMBDA_FUNCTION>");

Create job

Archimedes.create({
    jobType: "<JOB_TYPE>",
    inputData: {
        //<all json-like input data the job needs to know>
    },
    inputFiles: {
        //<all file-like input data like urls to s3 the job needs to know>
    },
    estimations: {
        //<all job meta metrics the system needs to know in order to triage job execution>
    }
}).then(job => {
    console.log(job);
}).catch(err => {
    console.log(err);
});

Run job

Archimedes.signal({
    jobId: job.id,
    state: "DISPATCH"
}).then().catch();    

Handle job

Payload for job execution will be:

{
  "id": "<JOB_ID>"
}

Then use Archimedes to get all job data including inputData and inputFiles:

let job = await Archimedes.get({
    jobId: "<JOB_ID>"
});

Then signal that we are executing this:

job = Archimedes.signal({
    jobId: job.id,
    state: "EXECUTE"
})

This will in particular now add a currentExecution object to the job object:

    let jobExecution = job.currentExecution; /* {
        executionId: 'XXX',
        createdAt: 'YYY',
        updatedAt: 'ZZZ',
        metrics: {},
        progress: 0,
        state: 'EXECUTE',
        failureReason: '',
        finishedAt: null
    } */

While you're executing you might want to periodically upgrade metrics (e.g. max cpu load, max memory usage etc.) as well as progress. This can be of use two-fold:

  • your own application might query this data to show job progress to the user
  • Archimedes is scanning jobs in the background for non-progression to make sure to kill and reschedule stuck jobs

To update progress and/or metrics:

    Archimedes.updateExecution({
        jobId: "XXX",
        executionId: jobExecution.executionId,
        progress: 0.5,
        metrics: {
            cpu: 1234,
            memory: 5678
        }
    })

Once you're done with the job, you can store your outputData and outputFiles like so:

    Archimedes.update({
        jobId: "XXX",
        outputData: {
            ...
        },
        outputFiles: {
            ...
        }
    })

And you transition the job to success or failure like so:

    Archimedes.signalExecution({
        jobId: "XXX",
        executionId: jobExecution.executionId,
        state: "SUCCESS" // "FAILURE"
     // failureReason: "XXXX" 
    })