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

gatsby-parallel-runner

v1.3.0

Published

Gatsby plugin that allows paralellization of external tasks

Downloads

267

Readme

Gatsby Parallel Runner

This is an early a parallel runner for gatsby that allows plugins and core parts of Gatsby to parallelize suited tasks such as image processing.

When gatsby is started from a parent process with the environment variable ENABLE_GATSBY_EXTERNAL_JOBS set, it will communicate some jobs up to the parent process via ipc, instead of running them in it's own internal queue.

This allows a parent process to orchestrate certain task across multiple workers for better parallelization through autoscaling cloud functions or the like.

Currently this plugin includes a processing queue implementation based on Google Cloud Functions, but the general abstractions in place should make it easy to add similar runtimes for other cloud providers or via different approaches to parallelization.

Installation and usage

Install in your gatsby project:

npm i gatsby-parallel-runner

To use with Google Cloud, set relevant env variables in your shell:

export GOOGLE_APPLICATION_CREDENTIALS=~/path/to/your/google-credentials.json
export TOPIC=parallel-runner-topic

Deploy the cloud function:

npx gatsby-parallel-runner deploy

Then run your Gatsby build with the parallel runner instead of the default gatsby build command.

npx gatsby-parallel-runner

Processor Queues, Processors and Implementations

Gatsby Parallel Runner comes with a set of core abstractions for parallelizing jobs.

The main orchestrator is the Processor Queue that gives invididual processors a simple interface for sending jobs to cloud functions and getting back results:

const result = await queue.process(job)

To do it's job, the ProcessorQueue needs a pubSubImplementation that must provide push(msg) and subscribe(handler) methods for enqueuing new jobs and receiving results.

Implementations are defined in src/processor-queue/implementations and there's currently just one of them based on Google's Cloud Functions.

The src/processors folder has the different processors that can be triggered via Gatsby's external job feature.

The processor folder must be named after the Redux event that should trigger it. Ie, the Image Processing processor gets triggered by the sharp plugin via an IMAGE_PROCESSING job, so the folder is called image-processing

Each processor can have a set of implementations based on the Processor Queue implementations available.

There's currently just one processor (image-processing), with an implementation for google-functions.

When running npx gatsby-parallel-runner deploy, the active processor queue implementation will make sure to deploy all the cloud function needed for the available processors.