Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

couch-continuum

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

couch-continuum - npm Package Compare versions

Comparing version 2.2.4 to 2.3.0

30

bin.js

@@ -23,3 +23,5 @@ #!/usr/bin/env node

target,
verbose
verbose,
allowReplications,
continuous
}) {

@@ -36,3 +38,5 @@ if (verbose) process.env.LOG = true

source,
target
target,
allowReplications,
continuous
})

@@ -113,2 +117,12 @@ }

default: true
},
allowReplications: {
description: 'Allow ongoing replications to the source database.',
default: false,
type: 'boolean'
},
continuous: {
description: 'Create a continuous replication from source to replica',
default: false,
type: 'boolean'
}

@@ -150,3 +164,3 @@ })

handler: async function (argv) {
const continuum = getContinuum(argv)
const continuum = getContinuum({ ...argv, allowReplications: true })
log(`Creating replica of ${continuum.source.host}${continuum.source.pathname} at ${continuum.target.host}${continuum.target.pathname}`)

@@ -217,2 +231,12 @@ await continuum.createReplica()

default: true
},
allowReplications: {
description: 'Allow ongoing replications to the source database.',
default: false,
type: 'boolean'
},
continuous: {
description: 'Create a continuous replication from source to replica',
default: false,
type: 'boolean'
}

@@ -219,0 +243,0 @@ })

@@ -148,3 +148,5 @@ const assert = require('assert').strict

source,
target
target,
allowReplications,
continuous
}) {

@@ -182,2 +184,4 @@ assert(couchUrl, 'The Continuum requires a URL for accessing CouchDB.')

this.replicateSecurity = replicateSecurity
this.allowReplications = allowReplications
this.continuous = continuous
// what's great for a snack and fits on your back

@@ -339,3 +343,7 @@ // it's log it's log it's log

log('[0/5] Checking if primary is in use...')
await this._isInUse(this.source.pathname.slice(1))
if (this.allowReplications) {
log('Skipping check because replications are allowed')
} else {
await this._isInUse(this.source.pathname.slice(1))
}
const lastSeq1 = await this._getUpdateSeq(this.source.href)

@@ -349,2 +357,10 @@ log(`[1/5] Creating replica db: ${this.target.host}${this.target.pathname}`)

await this._replicate(this.source, this.target, selector)
if (this.continuous) {
log(`Setting up continuous replication from ${this.source} to ${this.target}...`)
await request({
url: `${this.url.href}_replicate`,
method: 'POST',
json: { source: this.source.href, target: this.target.href, continuous: true }
})
}
log('[3/5] Verifying primary did not change during replication...')

@@ -361,3 +377,7 @@ const lastSeq2 = await this._getUpdateSeq(this.source.href)

log('[0/8] Checking if primary is in use...')
await this._isInUse(this.source.pathname.slice(1))
if (this.allowReplications) {
log('Skipping check because replications are allowed')
} else {
await this._isInUse(this.source.pathname.slice(1))
}
log('[1/8] Verifying primary and replica match...')

@@ -364,0 +384,0 @@ await this._verifyReplica()

2

package.json
{
"name": "couch-continuum",
"version": "2.2.4",
"version": "2.3.0",
"description": "Tool for migrating CouchDB databases to new configuration values.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -6,5 +6,2 @@ # couch-continuum

[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](https://standardjs.com)
[![Build Status](https://img.shields.io/travis/neighbourhoodie/couch-continuum/master.svg?style=flat-square)](https://travis-ci.org/neighbourhoodie/couch-continuum)
[![Coverage Status](https://img.shields.io/coveralls/github/neighbourhoodie/couch-continuum.svg?style=flat-square)](https://coveralls.io/github/neighbourhoodie/couch-continuum?branch=master)
[![Greenkeeper badge](https://badges.greenkeeper.io/neighbourhoodie/couch-continuum.svg)](https://greenkeeper.io/)

@@ -108,2 +105,6 @@ A tool for migrating CouchDB databases. It is useful for modifying database configuration values that can only be set during database creation, like `q` and `placement`. For example:

addition to its documents. [default: false]
--allowReplications Allow ongoing replications to the source
database [default: false]
--continuous Create a continuous replication from source to
replica [default: false]
--config Path to JSON config file

@@ -171,2 +172,2 @@ -h, --help Show help [boolean]

(c) 2018–2020 Neighbourhoodie Software & Open Source contributors
(c) 2018–2022 Neighbourhoodie Software & Open Source contributors

@@ -54,2 +54,20 @@ /* globals describe, it, beforeEach, before, afterEach, after */

}
try {
await request({
url: `${couchUrl}/_replicate`,
method: 'POST',
json: {
source: dbName,
target: `temp_copy_${dbName}`,
create_target: true,
continuous: true,
cancel: true
}
})
} catch (error) {
if (error.error !== 'not_found') {
throw error
}
}
})

@@ -223,2 +241,33 @@

it('should bypass isInUse when needed', async function () {
const continuum = new CouchContinuum({ couchUrl, source: dbName, allowReplications: true })
const opts =
{
url: `${couchUrl}/_replicate`,
method: 'POST',
json: {
source: dbName,
target: `temp_copy_${dbName}`,
create_target: true,
continuous: true
}
}
await request(opts)
await continuum.createReplica()
await request({ cancel: true, ...opts })
})
it('should create a new continuous replication if flag is given', async function () {
const continuum = new CouchContinuum({ couchUrl, source: dbName, continuous: true })
await continuum.createReplica()
const { jobs } = await request({
url: `${couchUrl}/_scheduler/jobs`,
json: true
})
const job = jobs.find(job => {
return job.source.includes(dbName) && job.target.includes(`temp_copy_${dbName}`)
})
assert(job)
})
describe('_isInUse', function () {

@@ -225,0 +274,0 @@ before(async function () {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc