Git Product home page Git Product logo

node-pg-lsn's Introduction

node-pg-lsn

Constants and functions for working with postgres xlog positions. This module makes a number of assumptions about the format of xlog positions. It's not totally clear that this is a committed Postgres interface, but it seems to be true.

We assume that postgres xlog positions are represented as strings of the form:

filepart/offset		e.g., "0/17BB660"

where both "filepart" and "offset" are hexadecimal numbers. xlog position F1/O1 is at least as new as F2/O2 if (F1 > F2) or (F1 == F2 and O1 >= O2). We try to avoid assuming that they're zero-padded (i.e., that a simple string comparison might do the right thing). We also don't make any assumptions about the size of each file, which means we can't compute the actual difference between two positions.

Usage

var assert = require('assert');
var lsn = require('pg-lsn');

var locationOne = '2D7/0';
var locationTwo = '2D6/FEFFE770';
var comparison = lsn.xlogCompare(locationOne, locationTwo);

if (comparison === 0) {
    console.log('locations are the same');
} else if(comparison > 0) {
    console.log('locationOne is greater than locationTwo');
} else {
    assert.ok(comparison < 0);
    console.log('locationOne is less than locationTwo');
}

node-pg-lsn's People

Contributors

cburroughs avatar

Stargazers

Krishna .V avatar Nicholas Van Doorn avatar Chris McCord avatar  avatar Hannes Ljungberg avatar

Watchers

Chris Prather avatar Max Bruning avatar Wyatt Preul avatar Jerry Jelinek avatar Nick Zivkovic avatar Michael Zeller avatar James Cloos avatar Jason King avatar Seong-Kook Shin avatar Dan McDonald avatar Mark Brooks avatar Brianna Bennett avatar Casey Bisson avatar Derek Crudgington avatar Credzba aka. Jing Ke avatar Travis Paul avatar Luiz Laranjeira avatar Ryan Puckett avatar Michael Hicks avatar Dylan avatar Dion Cuthbert avatar Luke Jarymowycz avatar Jhonas Wernery avatar Todd Whiteman avatar  avatar  avatar Jon Burgoyne avatar  avatar John Levon avatar Carol Cobine avatar  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.