forked from pinpoint-apm/pinpoint-node-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmethod-descriptor-builder.js
49 lines (39 loc) · 1.12 KB
/
method-descriptor-builder.js
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
/**
* Pinpoint Node.js Agent
* Copyright 2021-present NAVER Corp.
* Apache License v2.0
*/
'use strict'
const MethodDescriptor = require('./method-descriptor')
const MethodType = require('../constant/method-type').MethodType
class MethodDescriptorBuilder {
constructor(moduleName, objectPath, methodName) {
this.moduleName = moduleName
this.objectPath = objectPath
this.methodName = methodName
this.type = MethodType.DEFAULT
this.apiDescriptor = this.getDescriptor()
this.apiID = 0
}
setType(type) {
this.type = type
return this
}
setAPIDescriptor(apiDescriptor) {
this.apiDescriptor = apiDescriptor
return this
}
setAPIID(apiID) {
this.apiID = apiID
return this
}
build() {
return new MethodDescriptor(this.moduleName, this.objectPath, this.methodName, this.type, this.apiDescriptor, this.apiID)
}
getDescriptor() {
return [this.moduleName, this.objectPath, this.methodName]
.filter(v => v)
.join('.')
}
}
module.exports = MethodDescriptorBuilder