All Projects → valeriansaliou → Node Sonic Channel

valeriansaliou / Node Sonic Channel

Licence: mit
🦉 Sonic Channel integration for Node. Used in pair with Sonic, the fast, lightweight and schema-less search backend.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Node Sonic Channel

Alfred Npms
Alfred 3 workflow to search for npm packages with npms.io
Stars: ✭ 312 (+208.91%)
Mutual labels:  search, npm, npm-package
Sonic
🦔 Fast, lightweight & schema-less search backend. An alternative to Elasticsearch that runs on a few MBs of RAM.
Stars: ✭ 12,347 (+12124.75%)
Mutual labels:  graph, search, index
Vue Csv Import
Vue.js component to select a CSV file, map the columns to fields, and post it somewhere.
Stars: ✭ 95 (-5.94%)
Mutual labels:  npm, npm-package
Awesome Node Utils
some useful npm packages for nodejs itself
Stars: ✭ 51 (-49.5%)
Mutual labels:  npm, npm-package
Incompose
A inferno utility belt for function components and higher-order components
Stars: ✭ 76 (-24.75%)
Mutual labels:  npm, npm-package
Scrape Youtube
A lightning fast package to scrape YouTube search results. This was made and optimized for Discord Bots.
Stars: ✭ 43 (-57.43%)
Mutual labels:  search, npm
Nls
Missing inspector for npm packages.
Stars: ✭ 44 (-56.44%)
Mutual labels:  npm, npm-package
Package.json
文件 package.json 的说明文档。
Stars: ✭ 67 (-33.66%)
Mutual labels:  npm, npm-package
Yarpm
CLI tool to run npm scripts with either npm or yarn, depending on how it was started
Stars: ✭ 13 (-87.13%)
Mutual labels:  npm, npm-package
Node Fast Ratelimit
☔️ Fast and efficient in-memory rate-limit for Node, used to alleviate most common DOS attacks.
Stars: ✭ 84 (-16.83%)
Mutual labels:  npm, npm-package
Webcam Easy
javascript access webcam stream and take photo
Stars: ✭ 79 (-21.78%)
Mutual labels:  npm, npm-package
Event Target Shim
An implementation of WHATWG EventTarget interface, plus few extensions.
Stars: ✭ 89 (-11.88%)
Mutual labels:  npm, npm-package
Tplink Cloud Api
A node.js npm module to remotely control TP-Link smartplugs (HS100, HS110) and smartbulbs (LB100, LB110, LB120, LB130) using their cloud web service (no need to be on the same wifi/lan)
Stars: ✭ 96 (-4.95%)
Mutual labels:  npm, npm-package
Torrenter
Simple nodejs package to download torrents using torrent-indexer and webtorrent, especially movie and series.
Stars: ✭ 42 (-58.42%)
Mutual labels:  search, index
React Use Api
Async HTTP request data for axios. Designed for diverse UI states, SSR and data pre-caching.
Stars: ✭ 49 (-51.49%)
Mutual labels:  npm, npm-package
Actions Package Update
keeps npm dependencies up-to-date by making pull requests from GitHub Actions or CI.
Stars: ✭ 36 (-64.36%)
Mutual labels:  npm, npm-package
Packagephobia
⚖️ Find the cost of adding a new dependency to your project
Stars: ✭ 1,110 (+999.01%)
Mutual labels:  npm, npm-package
Angular File Uploader
Angular file uploader is an Angular 2/4/5/6/7/8/9/10 + file uploader module with Real-Time Progress Bar, Responsive design, Angular Universal Compatibility, localization and multiple themes which includes Drag and Drop and much more.
Stars: ✭ 92 (-8.91%)
Mutual labels:  npm, npm-package
Github Spray
Draw on your GitHub contribution graph ░▒▓█
Stars: ✭ 908 (+799.01%)
Mutual labels:  graph, npm-package
Blast
Blast is a full text search and indexing server, written in Go, built on top of Bleve.
Stars: ✭ 934 (+824.75%)
Mutual labels:  search, index

node-sonic-channel

Test and Build NPM Downloads Buy Me A Coffee

Sonic Channel integration for Node. Used in pair with Sonic, the fast, lightweight and schema-less search backend.

Sonic Channel lets you manage your Sonic search index, from your NodeJS code. Query your index and get search results, push entries to your index and pop them programmatically.

🇫🇷 Crafted in Nantes, France.

Who uses it?

Crisp

👋 You use sonic-channel and you want to be listed there? Contact me.

How to install?

Include sonic-channel in your package.json dependencies.

Alternatively, you can run npm install sonic-channel --save.

How to use?

1️⃣ Search channel

1. Create the connection

node-sonic-channel can be instanciated in search mode as such:

var SonicChannelSearch = require("sonic-channel").Search;

var sonicChannelSearch = new SonicChannelSearch({
  host : "::1",            // Or '127.0.0.1' if you are still using IPv4
  port : 1491,             // Default port is '1491'
  auth : "SecretPassword"  // Authentication password (if any)
}).connect({
  connected : function() {
    // Connected handler
    console.info("Sonic Channel succeeded to connect to host (search).");
  },

  disconnected : function() {
    // Disconnected handler
    console.error("Sonic Channel is now disconnected (search).");
  },

  timeout : function() {
    // Timeout handler
    console.error("Sonic Channel connection timed out (search).");
  },

  retrying : function() {
    // Retry handler
    console.error("Trying to reconnect to Sonic Channel (search)...");
  },

  error : function(error) {
    // Failure handler
    console.error("Sonic Channel failed to connect to host (search).", error);
  }
});

2. Query the search index

Use the same sonicChannelSearch instance to query the search index:

sonicChannelSearch.query("messages", "default", "valerian saliou")
  .then(function(results) {
    // Query results come there
  })
  .catch(function(error) {
    // Query errors come there
  });

3. Teardown connection

If you need to teardown an ongoing connection to Sonic, use:

sonicChannelSearch.close()
  .then(function() {
    // Close success handler
  })
  .catch(function(error) {
    // Close errors come there
  });

2️⃣ Ingest channel

1. Create the connection

node-sonic-channel can be instanciated in ingest mode as such:

var SonicChannelIngest = require("sonic-channel").Ingest;

var sonicChannelIngest = new SonicChannelIngest({
  host : "::1",            // Or '127.0.0.1' if you are still using IPv4
  port : 1491,             // Default port is '1491'
  auth : "SecretPassword"  // Authentication password (if any)
}).connect({
  connected : function() {
    // Connected handler
    console.info("Sonic Channel succeeded to connect to host (ingest).");
  },

  disconnected : function() {
    // Disconnected handler
    console.error("Sonic Channel is now disconnected (ingest).");
  },

  timeout : function() {
    // Timeout handler
    console.error("Sonic Channel connection timed out (ingest).");
  },

  retrying : function() {
    // Retry handler
    console.error("Trying to reconnect to Sonic Channel (ingest)...");
  },

  error : function(error) {
    // Failure handler
    console.error("Sonic Channel failed to connect to host (ingest).", error);
  }
});

2. Manage the search index

Use the same sonicChannelIngest instance to push text to the search index:

sonicChannelIngest.push("messages", "default", "conversation:1", "I met Valerian Saliou yesterday. Great fun!")
  .then(function() {
    // Push success handler
  })
  .catch(function(error) {
    // Push errors come there
  });

3. Teardown connection

If you need to teardown an ongoing connection to Sonic, use:

sonicChannelIngest.close()
  .then(function() {
    // Close success handler
  })
  .catch(function(error) {
    // Close errors come there
  });

3️⃣ Control channel

1. Create the connection

node-sonic-channel can be instanciated in control mode as such:

var SonicChannelControl = require("sonic-channel").Control;

var sonicChannelControl = new SonicChannelControl({
  host : "::1",            // Or '127.0.0.1' if you are still using IPv4
  port : 1491,             // Default port is '1491'
  auth : "SecretPassword"  // Authentication password (if any)
}).connect({
  connected : function() {
    // Connected handler
    console.info("Sonic Channel succeeded to connect to host (control).");
  },

  disconnected : function() {
    // Disconnected handler
    console.error("Sonic Channel is now disconnected (control).");
  },

  timeout : function() {
    // Timeout handler
    console.error("Sonic Channel connection timed out (control).");
  },

  retrying : function() {
    // Retry handler
    console.error("Trying to reconnect to Sonic Channel (control)...");
  },

  error : function(error) {
    // Failure handler
    console.error("Sonic Channel failed to connect to host (control).", error);
  }
});

2. Administrate your Sonic server

You may use the same sonicChannelControl instance to administrate your Sonic server.

3. Teardown connection

If you need to teardown an ongoing connection to Sonic, use:

sonicChannelControl.close()
  .then(function() {
    // Close success handler
  })
  .catch(function(error) {
    // Close errors come there
  });

List of channel methods

For details on argument values, see the Sonic Channel Protocol specification.

Search channel

  • sonicChannelSearch.query(collection_id<string>, bucket_id<string>, terms_text<string>, [options{limit<number>, offset<number>, lang<string>}<object>]?) ➡️ Promise(results<object>, error<object>)
  • sonicChannelSearch.suggest(collection_id<string>, bucket_id<string>, word_text<string>, [options{limit<number>}<object>]?) ➡️ Promise(results<object>, error<object>)

Ingest channel

  • sonicChannelIngest.push(collection_id<string>, bucket_id<string>, object_id<string>, text<string>, [options{lang<string>}<object>]?) ➡️ Promise(_, error<object>)
  • sonicChannelIngest.pop(collection_id<string>, bucket_id<string>, object_id<string>, text<string>) ➡️ Promise(count<number>, error<object>)
  • sonicChannelIngest.count<number>(collection_id<string>, [bucket_id<string>]?, [object_id<string>]?) ➡️ Promise(count<number>, error<object>)
  • sonicChannelIngest.flushc(collection_id<string>) ➡️ Promise(count<number>, error<object>)
  • sonicChannelIngest.flushb(collection_id<string>, bucket_id<string>) ➡️ Promise(count<number>, error<object>)
  • sonicChannelIngest.flusho(collection_id<string>, bucket_id<string>, object_id<string>) ➡️ Promise(count<number>, error<object>)

Control channel

  • sonicChannelControl.trigger(action<string>, [data<string>]?) ➡️ Promise(_, error<object>)
  • sonicChannelControl.info() ➡️ Promise(results<object>, error<object>)

What is Sonic?

ℹ️ Wondering what Sonic is? Check out valeriansaliou/sonic.

How is it linked to Sonic?

node-sonic-channel maintains persistent TCP connections to the Sonic network interfaces that are listening on your running Sonic instance. In case node-sonic-channel gets disconnected from Sonic, it will retry to connect once the connection is established again.

You can configure the connection details of your Sonic instance when initializing node-sonic-channel from your code; via the Sonic host and port.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].