idexlabs / idex.nucleus.core Goto Github PK
View Code? Open in Web Editor NEWIDEX Nucleus Core is the framework to build flexible, scalable and structured back-end architecture
License: MIT License
IDEX Nucleus Core is the framework to build flexible, scalable and structured back-end architecture
License: MIT License
The current benchmark is ~200 resource retrieved in 3 seconds.
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.
When updating a resource using the Resource API, the changes made to the object and persist it along with resource. As part of this feature, an action to rewind the resource to a specific version should also be implemented.
Part of the mechanism is in place, but not leveraged.
When an event is published, its key is pushed to a sorted list that should be used to make sure only one engine instance handles a given event.
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.
Refactor direct usage of the datastore's direct connection to Redis in the Resource API;
Like the datastore, an input validator should be interchangeable; right now, the default is the Nucleus validator.
When using autodiscovery, an engine's action's configuration are stored locally.
If an action was to be moved to another engine, the action's configuration would be stored under the second engine and the first.
The first engine should be able to clean after itself.
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
});
// ...
}
}
The feature would allow a user to specify code to be executed before and after a specific method.
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
When a Nucleus Datastore uses the blocking command BRPOP
(BLPOP
), the client cannot be destroyed properly.
When creating a relationship with a resource using the is-member-of
predicate, the system registers the object as anchor node to speed up queries; this relationship is never unregistered, ie: the anchor node's resource is removed.
The Nucleus Datastore API has a method to collapse an object to dot notation, currently it returns undefined when passed an object with an empty array.
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');
The Datastore API has to be more generic so it can be used interchangeably with the Resource API.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.