Giter Site home page Giter Site logo

idexlabs / idex.nucleus.core Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 9.0 655 KB

IDEX Nucleus Core is the framework to build flexible, scalable and structured back-end architecture

License: MIT License

JavaScript 95.87% Lua 4.13%
nodejs library microservice redis communication-protocol dataflow graph nucleus engine nucleus-engine

idex.nucleus.core's People

Contributors

antonborovoi avatar julbail13 avatar sebastienfilion avatar vizath avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

idex.nucleus.core's Issues

The engine doesn't throw an error if it has no name

Trying to instantiate an engine without a name doesn't throw an error, but part of the initialization code expects the value to be set.

const $engine = new NucleusEngine();

This throws a Nucleus Datastore error NucleusError: The item must be a string.

The name should be mandatory and throw a clear error when omitted.

The engine datastore and the resource datastore can't be separated

An engine requires a datastore connection which it uses to store engine specific data and passes to the Resource API; if a user chooses to pass a datastore adapter (not Redis), the engine won't be able to perform some low level tasks. The engine should accept, optionally a $resourceDatastore and a $cacheDatastore... Also, the engine should verify that the engine datastore is a Redis adapter.

Input validation adapter

Like the datastore, an input validator should be interchangeable; right now, the default is the Nucleus validator.

Share Redis connection for non-hanging Nucleus Datastore

It would be interesting to attempt to reduce the number of Redis connection in a given controlled ecosystem. If one or many engines are instantiated on the same node process, there is no point of having multiple Redis connection since they are both single threaded.
Hanging connection like those sued to subscribe to Redis commands or events should not share that connection for obvious reason.

class NucleusDatastore {
  constructor (datastoreName = 'Untitled', options = {}) {
    const {
      $logger = console,
      $$server,
      index: datastoreIndex = 0,
      port: datastorePort = 6379,
      URL: datastoreURL = 'localhost'
    } = options;

    this.name = datastoreName;
    this.index = datastoreIndex;

    this.$$handlerCallbackListByChannelName = {};
    this.scriptSHAbyScriptName = {};

    this.$$server = $$server || redis.createClient({
      db: datastoreIndex,
      host: datastoreURL,
      port: datastorePort
    });
  // ...
  }
}

Implement method hooks

The feature would allow a user to specify code to be executed before and after a specific method.

Errors rejected from a publish action request does not contain the meta

When using the #publishActionByNameAndHandleResponse method to publish an action and the action rejects with a Nucleus error containing some meta data, the error that is caught does not contain the meta data.

/**
 * @Nucleus ActionName ThrowErrorWithMetaData
 */
function () {

  throw new NucleusError(`This is a Nucleus error with meta data`, { testID: uuid.v4() }); 
}

...

$engine. publishActionByNameAndHandleResponse('ThrowErrorWithMetaData', {}, uuid.v4())
  .catch((error) => {
    error.meta.testID === undefined
  });

The Nucleus error is correctly store in the action, so the issue probably comes from the NucleusError constructor. library/Error.nucleus.js

The Nucleus error is rebuilt around library/Engine.nucleus.js:740.

Might be related to: #14

Deep hash structure are not expanded properly

When retrieving a deep hash structure, the datastore tries to spread the data using dot notation to allow for the data to be searchable. A structure containing an array should use "bracket notation" and be expanded to an array as expected.

const object = {
  key: [
    'value1',
    'value2'
  ];

const expandedObject = NucleusDatastore.expandDotNotationObject(object);

chai.expect(expandedObject.key[0]).to.equal('value1');

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.