Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8505cb5
feat(nodejs): HTTP transport, configuration string, new config options
glasstiger Apr 15, 2024
487b504
feat(nodejs): HTTP transport, configuration string, new config options
glasstiger Apr 17, 2024
d2b433d
Update src/sender.js
glasstiger Apr 22, 2024
408dcd0
Update src/sender.js
glasstiger Apr 22, 2024
da538fb
Update src/options.js
glasstiger Apr 22, 2024
5d864de
Update src/options.js
glasstiger Apr 22, 2024
669234f
Update src/options.js
glasstiger Apr 22, 2024
3a1e407
Update src/options.js
glasstiger Apr 22, 2024
7330c75
Update src/options.js
glasstiger Apr 22, 2024
feeb940
Update types/src/sender.d.ts
glasstiger Apr 22, 2024
9fef9f3
Update src/options.js
glasstiger Apr 22, 2024
1d0c64e
Update src/options.js
glasstiger Apr 22, 2024
efeaef2
use sender's logger
glasstiger Apr 22, 2024
7cb6c57
destroy request before retry
glasstiger Apr 23, 2024
c16bf65
fix test to work with different node versions
glasstiger Apr 23, 2024
9b9c4d0
custom http agent option
glasstiger Apr 24, 2024
64ffab8
custom http agent options
glasstiger Apr 24, 2024
994318c
destroy default http agents when last sender is closed
glasstiger Apr 24, 2024
f5d5ab3
buffer size comment + jsdoc fix
glasstiger Apr 24, 2024
390a524
tsc + jsdoc generated
glasstiger Apr 24, 2024
9b607b9
fixing tests
glasstiger Apr 24, 2024
f2a5a74
fix test depends on node version
glasstiger Apr 24, 2024
c241667
Update src/options.js
glasstiger Apr 25, 2024
b0dd22e
separate counters for http and tcp
glasstiger Apr 25, 2024
62dfc53
Merge remote-tracking branch 'origin/main' into ilp_http
glasstiger Apr 25, 2024
a5f1616
examples
glasstiger Apr 25, 2024
69194c1
examples
glasstiger Apr 25, 2024
9b72021
examples
glasstiger Apr 25, 2024
bd278c6
make protocol option mandatory
glasstiger Apr 29, 2024
fefb850
remove sender instance counters
glasstiger Apr 29, 2024
689005e
improve docs
glasstiger Apr 29, 2024
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove sender instance counters
  • Loading branch information
glasstiger committed Apr 29, 2024
commit fefb8506af60ccf4676e168db130b6ea5fb0458a
28 changes: 5 additions & 23 deletions src/sender.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ const PUBLIC_KEY = {
class Sender {
/** @private */ static DEFAULT_HTTP_AGENT;
/** @private */ static DEFAULT_HTTPS_AGENT;
/** @private */ static numOfSenders = { http: 0, tcp: 0 };

/** @private */ http; // true if the protocol is HTTP/HTTPS, false if it is TCP/TCPS
/** @private */ secure; // true if the protocol is HTTPS or TCPS, false otherwise
Expand Down Expand Up @@ -205,8 +204,6 @@ class Sender {
this.maxBufferSize = isInteger(options.max_buf_size, 1) ? options.max_buf_size : DEFAULT_MAX_BUFFER_SIZE;
this.resize(isInteger(options.init_buf_size, 1) ? options.init_buf_size : DEFAULT_BUFFER_SIZE);
this.reset();

Sender.numOfSenders[this.http ? HTTP : TCP]++;
}

/**
Expand Down Expand Up @@ -384,26 +381,11 @@ class Sender {
* Data sitting in the Sender's buffer will be lost unless flush() is called before close().
*/
async close() {
if (this.http) {
Sender.numOfSenders.http--;
if (Sender.numOfSenders.http < 1) {
if (Sender.DEFAULT_HTTP_AGENT) {
Sender.DEFAULT_HTTP_AGENT.destroy();
Sender.DEFAULT_HTTP_AGENT = undefined;
}
if (Sender.DEFAULT_HTTPS_AGENT) {
Sender.DEFAULT_HTTPS_AGENT.destroy();
Sender.DEFAULT_HTTPS_AGENT = undefined;
}
}
} else {
Sender.numOfSenders.tcp--;
if (this.socket) {
const address = this.socket.remoteAddress;
const port = this.socket.remotePort;
this.socket.destroy();
this.log('info', `Connection to ${address}:${port} is closed`);
}
if (this.socket) {
const address = this.socket.remoteAddress;
const port = this.socket.remotePort;
this.socket.destroy();
this.log('info', `Connection to ${address}:${port} is closed`);
}
}

Expand Down
12 changes: 7 additions & 5 deletions test/mockhttp.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ const https = require('https');
class MockHttp {
server;
mockConfig;
numOfRequests = 0;
numOfRequests;

constructor(mockConfig) {
if (!mockConfig) {
throw new Error('Missing mock config');
}
constructor() {
this.reset();
}

reset(mockConfig = {}) {
this.mockConfig = mockConfig;
this.numOfRequests = 0;
}

async start(listenPort, secure = false, options = undefined) {
Expand Down
Loading