Skip to content

Commit

Permalink
pinpoint-apm#86 method descriptor Builder
Browse files Browse the repository at this point in the history
  • Loading branch information
feelform committed Jun 9, 2021
1 parent 3faaf4f commit 288bfc6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
26 changes: 26 additions & 0 deletions lib/context/method-descriptor-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,33 @@

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()
}
Expand Down
9 changes: 7 additions & 2 deletions lib/context/method-descriptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ const MethodType = require('../constant/method-type').MethodType

// https://github.com/pinpoint-apm/pinpoint/blob/master/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/AbstractRecorder.java
class MethodDescriptor {
constructor(moduleName, objectPath, methodName, type, apiDescriptor) {
constructor(moduleName, objectPath, methodName, type, apiDescriptor, apiId) {
this.moduleName = moduleName
this.objectPath = objectPath
this.methodName = methodName
this.type = type || MethodType.DEFAULT
this.apiDescriptor = apiDescriptor || this.getDescriptor()
this.apiId = 0

if (typeof apiId === 'number') {
this.apiId = apiId
} else {
this.apiId = 0
}
}

static create(moduleName, objectPath, methodName) {
Expand Down

0 comments on commit 288bfc6

Please sign in to comment.