1.0.0 • Published 8 years ago

status-manager v1.0.0

Weekly downloads
1
License
MIT
Repository
-
Last release
8 years ago

#简单状态管理

某些任务的执行需要依赖其他基础配置的正确,例如数据库连接, 可以在数据库连接成功时,设置连接状态为true,失败时设为false, 可以在执行任务前使用whether对依赖的状态进行判断。

##方法 set(key,value); get(key) return value; switch(key) set value=!value , return value; whether(keys..) return whether the keys are all true;

##示例

var sm = require('status-manager');

sm.set('mysql',true);
sm.set('redis',true);
sm.set('mongodb',false);
sm.set('net',false);

if(sm.whether('mysql','redis')){
    console.log('mysql and redis has ready!')
}else{
    console.log('mysql and redis has not ready!')
}

if(sm.whether('mysql','mongodb')){
    console.log('mysql and mongodb has ready!')
}else{
    console.log('mysql and mongodb has not ready!')
}

if(sm.whether('mongodb','net')){
    console.log('mongodb and net has ready!')
}else{
    console.log('mongodb and net has not ready!')
}