npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

deepstream.io-storage-cockroachdb

v1.0.3

Published

CockroachDB connector for using as storage connector with Deepstream.io

Downloads

9

Readme

deepstream.io-storage-cockroachdb npm version Build Status

Deepstream.io storage connector for CockroachDB

What is CockroachDB?

CockroachDB is database server which is used as scalable replacement of MySQL. It partially supports PostgreSQL syntax involving some unique stylings. It is scalable by default and running seemlessly local, so properly configurated server instances may be manipulated even by Bash script. CockroachDB is initially distributed and performs proper data exchange between nodes automatically which makes possible strong consistence and high stability of your data storage.

Why use CockroachDB with Deepstream?

CockroachDB is one of supported connectors for Deepstream which is used for data recording. It is modified to get PostgreSQL-based relational storage working with Deepstream data structure which are JSON blobs identified by keys. CockroachDB is focused on high stability and scalability of several separated workers with access to same data storages.

Downsides?

You need at least one properly working CockroachDB worker to get this connector running. Also there is no SSL-certs authentication yet supported for accessing CockroachDB workers so you must use classic login/password credentials.

Using CockroachDB with Deepstream

Deepstream can connect to CockroachDB using the "CockroachDB storage connector", a plugin that connects to the database and automatically syncs incoming and outgoing record updates.

Installing the CockroachDB storage connector

You can install the CockroachDB storage connector via Deepstream's commandline interface, using:

deepstream install storage cockroachdb

or in Windows:

deepstream.exe install storage cockroachdb

resulting in Deepstream CockroachDB connector install command line output.

If you're using Deepstream's Node.js interface, you can also install it as an NPM module:

npm i perimetral/deepstream.io-storage-cockroachdb

Configuring the CockroachDB storage connector

You can configure the storage connector plugin in deepstream with the following options considering there are additional ones which are must be set at CockroachDB config (look here for details):

You may use Deepstream YAML config file with such formatting:

plugins:
  storage:
    name: deepstream.io-storage-cockroachdb
    options:
      ds_cockroach: 'postgresql://root@localhost:26257?sslmode=disable'
      ds_dbName: 'deepstream'
      ds_tableName: 'deepstream_storage'
      ds_keyType: 'text'
      ds_valueType: 'text'
      ds_splitter: '/'

Where:

  • ds_cockroach: PostgreSQL connection string
  • ds_databaseName, ds_tableName: data preferences (if such database or table are missing new one is created with specified name)
  • ds_keyType, ds_valueType: data types for data recording (all of input will be converted to this types)
  • ds_splitter: string which determines symbols to split category and exactly key in key argument passed for data manipulating

Usage example

Here is simple example of connecting and using of CockroachDB connector:

let ds = require('deepstream.io');
let connector = require('deepstream.io-storage-cockroachdb');
let server = new ds();
server.set('storage', new connector({}));
server.start();

//  AFTER THIS YOU ARE ABLE TO PERFORM ALL OF CLASSIC DEEPSTREAM DATA MANIPULATIONS
//  AND ALL OF THEM WILL BE PROCESSED BY COCKROACHDB CONNECTOR

Configuring from Javascript

If you installed connector as NPM plugin, you may reconfigure it right in runtime like here:

server.set('storage', new connector({
  cockroach: 'postgresql://root@localhost:26257?sslmode=disable',
  dbName: 'deepstream',
  tableName: 'deepstream_storage',
  keyType: 'text',
  valueType: 'text',
  splitter: '/',
}));

Do not forget to run server.start() after connecting and configuring connector. Yay!