
Security News
Potemkin Understanding in LLMs: New Study Reveals Flaws in AI Benchmarks
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
multilevel-agent
Advanced tools
makes multilevel server/client simpler and stronger, with auto restart and reconnect.
makes multilevel server/client simpler, with auto restart and reconnect.
npm install multilevel-agent
var multilevelAgent = require('multilevel-agent');
var server = multilevelAgent.Server([options]);
The options
could have below properties:
false
as default.8081
as default.var server = multilevelAgent.Server({
location: __dirname + '/db/',
port: 8090,
valueEncoding: 'json',
auth: function (user, cb) {
if (user.name == 'root' && user.pass == 'p@ss') {
cb(null, {name: 'root'});
} else {
cb(new Error('not authorized'));
}
},
access: function (user, db, method, args) {
if (!user || user.name !== 'root') {
if (/^put|^del|^batch|write/i.test(method)) {
throw new Error('read-only access');
}
}
}
});
See more from example/server.js
.
Emitted when an error occurs, e.g.:
server.on('error', function(err){
});
The err
is an instance of Error
, and in addition, err
has one more property err.source
, see more from sources.
Emitted when a new TCP connection is made, e.g.:
server.on('connect', function(){
});
Emitted when the server/client/database closes, e.g.:
server.on('close', function(agent){
});
agent including two properties:
This event is very important, and you can use agent.source
to identify who emitted 'close'
event, it could be one of sources. If it is 'tcp_server'
or 'database'
, it means server or database has just crashed, you'd better restart your server. If you are using pm2
, just exist the process then pm2
will auto restart your server:
server.on('close', function(agent){
if(agent.source == multiAgent.Server.source.TCP_SERVER || agent.source == multiAgent.Server.source.DATABASE){
process.exit(0);
return;
}
// tcp_client closed? screw it.
});
Just start the server, if autostart
is set to true
, this effects nothing.
server.start();
If current state
equals multiAgent.Server.state.RUNNING
, stops the server.
Notes: The server is finally closed when all connections are ended and the server emits a 'close'
event. So, if you really wanna shut down the server, just try process.exit(0)
.
server.stop();
The restructuring options.
console.log(server.options);
The current state of server, see more from states.
The port of TCP server.
var client = multilevelAgent.Client([options]);
The options
could have below properties:
var client = multilevelAgent.Client({
host: 'localhost',
port: 8090
});
See more from example/client.js
.
Access multilevel's APIs through client.db
, e.g.:
client.db.put('KEY', 'VALUE');
client.db.get('KEY', function(err, value){
});
// ...
Emitted when an error occurs, e.g.:
server.on('error', function(err){
});
The err
is an instance of Error
, and in addition, err
has one more property err.source
, see more from sources.
Emitted when a new TCP connection or Database is made, e.g.:
server.on('connect', function(){
});
Emitted when reconnecting to datababase/tcp server, e.g.:
client.on('reconnecting', function(recon){
})
The reconn
indluding two properties:
The restructuring options.
console.log(server.options);
The current state of server, see more from states.
multiAgent.Server.source.DATABASE
.multiAgent.Server.source.TCP_CLIENT
.multiAgent.Server.source.TCP_SERVER
.multiAgent.Server.source.LEVEL_SERVER
.multiAgent.Client.source.DATABASE
.multiAgent.Client.source.TCP_CLIENT
.multiAgent.Client.source.RPC_STREAM
.multiAgent.Client.source.LEVEL_SERVER
.multiAgent.Server.state.INIT
.multiAgent.Server.state.RUNNING
.multiAgent.Server.state.STOP
.multiAgent.Client.state.INIT
.multiAgent.Client.state.RUNNING
.multiAgent.Client.state.STOP
.Only test options
.
npm test
Manual test:
First: start server
node example/server
Second: run client
node example/client
If you wanna make different tests, just edit the scripts under example folder.
Copyright 2014 Tjatse
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
FAQs
makes multilevel server/client simpler and stronger, with auto restart and reconnect.
The npm package multilevel-agent receives a total of 5 weekly downloads. As such, multilevel-agent popularity was classified as not popular.
We found that multilevel-agent demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.