1.1.4 • Published 1 year ago

@lifeomic/double-check v1.1.4

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

This package provides a utility for comparing the behavior of two function invocations in parallel, using different arguments.

It's especially useful for exercising the behavior of a certain block of code in a blue-green scenario, and comparing the results between a primary + secondary configuration.

Installation

yarn add @lifeomic/double-check

Usage

import { compare } from '@lifeomic/double-check';

const response = await compare({
  configurations: {
    // Specify a primary configuration.
    primary: {
      databaseClient: primaryDatabaseClient,
    },
    // Specify an optional secondary configuration.
    secondary: {
      databaseClient: secondaryDatabaseClient,
    },
  },

  // Specify the operation you'd like to perform using the configuration.
  operation: ({ databaseClient }) => {
    return databaseClient.query('SELECT * FROM users');
  },

  // Specify a secondary timeout.
  cutoffSecondaryAfterMs: 300,
});

// The response contains:

// The primary result.
response.primaryResult;

// A comparison of the results, if a secondary configuration was specified.
//
// This report should be logged and examined over time to analyze similarity between
// the primary + secondary configurations.
response.report;

// The error from the secondary operation, if it failed.
response.secondaryError;
1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago