Git Product home page Git Product logo

gatsby-parallel-runner's Introduction

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.

gatsby-parallel-runner's People

Contributors

biilmann avatar jlengstorf avatar lannonbr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.