kafka 查看当前有多少group
1 | kafka-run-class.bat kafka.admin.ConsumerGroupCommand --zookeeper localhost:2181 --list |
kafka 查看group情况
1 | kafka-run-class.bat kafka.admin.ConsumerGroupCommand --zookeeper localhost:2181 --describe --group console-consumer-8047 |
1 | Box.prototype._getExistingFiles = function(){ |
我们看到this.Cache.find
这句代码是从缓存中查找,那么Cache是什么呢?
1 |
|
是从models文件夹下注册的model,然后把model放入db中。
1 | Database.prototype.model = function(name, schema){ |
我们看下Cache
的Model:1
2
3
4
5
6
7
8
9module.exports = function(ctx){
var Cache = new Schema({
_id: {type: String, required: true},
shasum: {type: String},
modified: {type: Number, default: Date.now}
});
return Cache;
};
声明了一个Schema,Scheme构造函数中会把当前schema参数加入path中,以便于查询1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82if (schema){
this.add(schema);
}
Schema.prototype.add = function(schema, prefix_){
var prefix = prefix_ || '';
var keys = Object.keys(schema);
var len = keys.length;
var key, value;
if (!len) return;
for (var i = 0; i < len; i++){
key = keys[i];
value = schema[key];
this.path(prefix + key, value);
}
};
Schema.prototype.path = function(name, obj){
if (obj == null){
return this.paths[name];
}
var type;
var nested = false;
if (obj instanceof SchemaType){
type = obj;
} else {
switch (typeof obj){
case 'function':
type = getSchemaType(name, {type: obj});
break;
//比如Cache的model就是{type: String, required: true}
case 'object':
if (obj.type){
type = getSchemaType(name, obj);
} else if (isArray(obj)){
type = new Types.Array(name, {
child: obj.length ? getSchemaType(name, obj[0]) : new SchemaType(name)
});
} else {
type = new Types.Object();
nested = Object.keys(obj).length > 0;
}
break;
default:
throw new TypeError('Invalid value for schema path `' + name + '`');
}
}
this.paths[name] = type;
this._updateStack(name, type);
if (nested) this.add(obj, name + '.');
};
function getSchemaType(name, options){
var Type = options.type || options;
var typeName = Type.name;
//String就是内置的类型
if (builtinTypes[typeName]){
return new Types[typeName](name, options);
} else {
return new Type(name, options);
}
}
var builtinTypes = {
String: true,
Number: true,
Boolean: true,
Array: true,
Object: true,
Date: true
};
最重要的就是各种Types:
1 | exports.Mixed = require('../schematype'); |
比如String:
1 | function SchemaTypeString(name, options){ |
这边的match方法就是在schema类的_parseQuery中有可能用到的,下回再讲。
hexo list命令是由hexo实例调用的
1 | //调用hexo类的call方法 |
先调用list命令:1
2
3
4
5
6
7
8
9
10
11
12
13
14function listConsole(args){
/* jshint validthis: true */
var type = args._.shift();
var self = this;
// Display help message if user didn't input any arguments
if (!type || !store.hasOwnProperty(type)){
return this.call('help', {_: ['list']});
}
return this.load().then(function(){
return store[type].call(self, args);
});
}
加载数据库,统计数量1
2
3
4
5
6
7
8
9
10
11
12
13Hexo.prototype.load = function(callback){
var self = this;
return loadDatabase(this).then(function(){
//处理 插入数据库操作
return Promise.all([
self.source.process(),
self.theme.process()
]);
}).then(function(){
return self._generate({cache: true});
}).nodeify(callback);
};
1 | 'use strict'; |
1 | var data = { |
1 | //默认layout为post |
1 | var split = yfm.split(scaffold); |
1 | var frontMatter = prepareFrontMatter(_.clone(data)); |
最后调用 swig模板引擎 编译splitedata对象
1 | var renderedData = swig.compile(split.data)(frontMatter); |
首先在构造函数里初始化配置文件路径1
2
3//_config.yml就是根目录下的
this.config_path = args.config ? pathFn.resolve(base, args.config)
: pathFn.join(base, '_config.yml');
hexo有个默认的配置文件
1 | 'use strict'; |
1 | this.config = _.clone(defaultConfig); |
随后在init函数中初始化配置:
1 | // Load config |
init函数就是在hexo-cli/hexo.js中加载完hexo模块后就调用的:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18return findPkg(cwd, args).then(function(path) {
if (!path) return;
hexo.base_dir = path;
return loadModule(path, args).catch(function() {
log.error('Local hexo not found in %s', chalk.magenta(tildify(path)));
log.error('Try running: \'npm install hexo --save\'');
process.exit(2);
});
}).then(function(mod) {
if (mod) hexo = mod;
log = hexo.log;
require('./console')(hexo);
return hexo.init();
})