1.3.0 • Published 4 years ago

gatsby-parallel-runner v1.3.0

Weekly downloads
529
License
MIT
Repository
github
Last release
4 years ago

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.

1.3.0

4 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.2.0-beta.0

4 years ago

1.1.3

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.1.0-beta.2

4 years ago

1.1.0-beta.1

4 years ago

1.1.0-beta.0

4 years ago

1.0.23

4 years ago

1.0.22

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.10

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago