0.5.2 • Published 7 months ago

@gatsby-cloud-pkg/merlin-synchronizer v0.5.2

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Merlin Synchronizer

The synchronizer is responsible for pulling data from a Merlin ledger in GCS via the Gatsby Cloud Ledger API. It can sync all data in a ledger or just the data since the last time it synchronized.

It synchronizes Merlin ledger redux actions for a specific Gatsby Cloud site ID and a specific Gatsby site path local to the process calling synchronize. It handles its own caching via a provided cache function with get and set methods. It returns a promise that's resolved when all actions are synced or its determined that the synchronizer can be invoked in any follower when they need to sync data from Cloud.

Usage

import { synchronize } from "@gatsby-cloud-pkg/merlin-synchronizer"

const { ledgerExists } = await synchronize({
  siteId, // should be a site ID for a Gatsby Cloud site
  gatsbySitePath, // should be an absolute path to a Gatsby site on disk
  cache, // needs cache.get and cache.set methods
  // sourcingConfigurationId, <-- this is optional. a sourcingConfigurationId will be computed from the Gatsby site at the gatsbySitePath. But you can pass this directly too
  handleAction: (action) => {
    // do stuff with this action
    // it's a Gatsby core redux action which was emitted in Merlin and stored in GCS
  },
})
import { computeSourcingConfigurationId } from "@gatsby-cloud-pkg/merlin-synchronizer"

// ...
const sourcingConfigurationId = await computeSourcingConfigurationId(
  pathToGatsbySite
)

Development

You must have previously written a ledger to disk. You can do this by running yarn:start:local in services/cloud-sourcerer in the mansion repo. You may need to set environment variables for the site you are using to generate the ledger.

  1. Run dev-monolith with yarn:start:local in services/dev-monolith
  2. Create an env file with the SITE_ID you used to generate the ledger and the correct port for the API, e.g. GATSBY_CLOUD_DATALAYER=http://localhost:8201/get-ledger-entries if not using 8083
  3. Run yarn run:local in the merlin-synchronizer directory.
0.5.0

10 months ago

0.4.0

10 months ago

0.5.2

7 months ago

0.5.1

10 months ago

0.3.8

1 year ago

0.3.7

1 year ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago