Skip to content

Indexing strategies for the neume network.

License

Notifications You must be signed in to change notification settings

neume-network/strategies

Repository files navigation

neume-network-strategies

purpose

The goal of this repository and the overall idea of separating neume-network-core's source from its strategies, is to allow any type of music platform to quickly define their on-chain schema - allowing them to re-use neume-network-core to index and distribute their and other platform's music ecosystem.

installation and contributing

  • It's best to install the strategies repository via neume-network/core as npm i will download the submodule and install its dependencies
  • To run the tests via npm run test a properly set up .env is necessary. We recommend softlinking from core's .env file using ln

implementing new strategies

Checkout the quickstart guide for a in-depth walkthrough.

high-level checklist for implementation

  • Any external request message passed to @neume-network/extraction-worker must result in an idempotent response (aka. if the request is repeated the same result must be returned).
  • Extraction of information from external requests must not be coupled to e.g. transformation of responses. It must be possible to run transformation independently from e.g. extraction.
  • Request patterns should be scoped through e.g. time or block periods.

To implement a strategy with maximum efficiency, we recommend doing all on-chain and off-chain requests using the extraction Worker API.

extractor strategy interface definition

An extractor strategy must implement the following interface:

interface Extractor {
  name: String;
  init(args...): Object<messages:  Message[], write: String>;
  update(message: Message): Object<messages: Message[], write: String>;
}

Where Message is defined as any JSON object compliant to the definitions in neume-network/message-schema.

A neume-network extraction message is layed out similarly to a react.js component in that foundamentally, it is a component implementing lifecycle methods.

  • The init function is called when the component is mounted into the core process.
  • Upon completion of the init task, update is called until update's returned messages list is empty.

Below is a visual overview of a neume-network extractor component's lifecycle.

transformer strategy interface definition

A transformer strategy must implement the following interface:

interface Transformer {
  name: String;
  onLine(line: String): String | null | undefined;
  onError(error: Error): any;
  onClose(): String | null | undefined;
}

Where Message is defined as any JSON object compliant to the definitions in neume-network/message-schema.

About

Indexing strategies for the neume network.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published