forked from pinpoint-apm/pinpoint-node-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pinpoint-apm#182] agentInfo retry tests
- Loading branch information
Showing
7 changed files
with
215 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* Pinpoint Node.js Agent | ||
* Copyright 2020-present NAVER Corp. | ||
* Apache License v2.0 | ||
*/ | ||
|
||
'use strict' | ||
|
||
const grpc = require('@grpc/grpc-js') | ||
|
||
class CallArguments { | ||
constructor(callback) { | ||
this.callback = callback | ||
} | ||
|
||
getCallback() { | ||
return this.callback | ||
} | ||
|
||
getMetadata() { | ||
return this.metadata | ||
} | ||
|
||
getOptions() { | ||
const options = this.options | ||
if (this.deadlineMilliseconds) { | ||
const deadline = new Date() | ||
deadline.setMilliseconds(deadline.getMilliseconds() + this.deadlineMilliseconds) | ||
options.deadline = deadline | ||
} | ||
return options | ||
} | ||
} | ||
|
||
const DEFAULT_CLIENT_REQUEST_TIMEOUT = 6000 | ||
class CallArgumentsBuilder { | ||
constructor(callback) { | ||
this.callback = callback | ||
this.metadata = new grpc.Metadata() | ||
this.options = {} | ||
} | ||
|
||
setDeadlineMilliseconds(deadlineMilliseconds) { | ||
this.deadlineMilliseconds = deadlineMilliseconds | ||
return this | ||
} | ||
|
||
setMetadata(key, value) { | ||
this.metadata.set(key, value) | ||
return this | ||
} | ||
|
||
build() { | ||
const callArguments = new CallArguments(this.callback) | ||
callArguments.metadata = this.metadata | ||
callArguments.options = this.options | ||
callArguments.deadlineMilliseconds = this.deadlineMilliseconds || DEFAULT_CLIENT_REQUEST_TIMEOUT | ||
return callArguments | ||
} | ||
} | ||
|
||
module.exports = CallArgumentsBuilder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.