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

gun-cassandra

v1.0.4

Published

Cassandra persistence layer for Gun DB

Downloads

8

Readme

Gun-Cassandra

CQL/Cassandra native persistence layer for gun

GUN is a realtime, distributed, offline-first, graph database engine.

THIS IS EXPERIMENTAL WORK IN PROGRESS! USE AT YOUR OWN RISK!

Comments and PR/Contributions are super welcome!


Installation

npm install gun-cassandra

Usage

var Gun = require('gun');
require('gun-cassandra');

var gun = Gun({
  file: false // turn off pesky file.js data.json default
  , db: {
	contactPoints: ['127.0.0.1'], 
	keyspace: 'gun'
  }
});

Fluffy's Test

The following script runs Fluffy's test successfully. Speed is ridicolously low when initializing keyspace and table.

GUN -> CQL <- GUN

var cat = {name: "Fluffy", species: "kitty"};
var mark = {boss: cat};
cat.slave = mark;
gun.get('mark').put(mark);
cqlsh> SELECT * FROM gun_db.gun_data;

 soul                 | field   | relation             | state         | value
----------------------+---------+----------------------+---------------+--------
 jccj3klhbH4laGweIBiP |    name |                      | 1515798170328 | Fluffy
                 mark |    boss | jccj3klhbH4laGweIBiP | 1515798170328 |       
 jccj3klhbH4laGweIBiP |   slave |                 mark | 1515798170328 |       
 jccj3klhbH4laGweIBiP | species |                      | 1515798170328 |  kitty
gun.get('mark').get('boss').get('name').val(function(data, key){
  // `val` grabs the data once, no subscriptions.
  console.log("Mark's boss is", data);
});
Output:
Mark's boss is Fluffy

CQL <- GUN

cqlsh> INSERT INTO gun_db.gun_data JSON '{ "soul": "jcdkfchqWeSXR7dzFJdU", "field": "gender", "state": 1515860865492, "relation": "", "value": "male"}';
gun.get('mark').get('boss').get('gender').val(function(data, key){
   console.log("Mark's boss gender is", data);
   process.exit(0);
});
Output:
Mark's boss gender is male
Test Script
# nodejs test/simple.js 
Hello wonderful person! :) Thanks for using GUN, feel free to ask for help on https://gitter.im/amark/gun and ask StackOverflow questions tagged with 'gun'!
> Cassandra Cluster connected!
> Gun-Cassandra Tables Ready!
> waiting 10 seconds...
Mark's boss is Fluffy

## nodejs test/simple-read.js 
Hello wonderful person! :) Thanks for using GUN, feel free to ask for help on https://gitter.im/amark/gun and ask StackOverflow questions tagged with 'gun'!
reading from CQL...
Cassandra Cluster connected!
Gun-Cassandra Tables Ready!
Mark's boss is Fluffy
Boss is a kitty
Cassandra Schema (SimpleStrategy)
cqlsh> DESC KEYSPACE gun_db ;

CREATE KEYSPACE gun_db WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}  AND durable_writes = true;

CREATE TABLE gun_db.gun_data (
    soul text,
    field text,
    relation text,
    state bigint,
    value text,
    PRIMARY KEY ((soul, field))
) WITH bloom_filter_fp_chance = 0.01
    AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
    AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND crc_check_chance = 1.0
    AND dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 0
    AND gc_grace_seconds = 864000
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = '99PERCENTILE';

Elassandra Schema (NetworkTopologyStrategy)
cqlsh> ALTER KEYSPACE gun_db WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'DC1' : 1 } AND DURABLE_WRITES = true;
cqlsh> DESC KEYSPACE gun_db ;

CREATE KEYSPACE gun_db WITH replication = {'class': 'NetworkTopologyStrategy', 'DC1': '1'}  AND durable_writes = true;

CREATE TABLE gun_db.gun_data (
    soul text,
    field text,
    relation text,
    state bigint,
    value text,
    PRIMARY KEY ((soul, field))
) WITH bloom_filter_fp_chance = 0.01
    AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
    AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND crc_check_chance = 1.0
    AND dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 0
    AND gc_grace_seconds = 864000
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = '99PERCENTILE';
CREATE CUSTOM INDEX elastic_gun_data_idx ON gun_db.gun_data () USING 'org.elassandra.index.ExtendedElasticSecondaryIndex';

Changelog

  • 1.0.1 first version for gun 0.9.x based on node-db

TODO

  • [ ] Cleanup Gun>Cassandra insert logic
  • [ ] Docker Test Builders (Cassandra 3.11, Elassandra 5.5.0.9)
  • [ ] Modularize CQL queries (named query in CassanKnex)
  • [ ] Stress-Performance Test

Acknowledgement

Gun is open-sourced and copyrighted by Mark Nadal

Apache Cassandra, Apache Lucene, Apache, Lucene, Solr, TinkerPop, and Cassandra are trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries.

Based on vfs-gun-db by d3x0r