-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add e2e test setup for working with winston 3.x support while keeping…
… 2.x support (#60) * add basic setup for testing with real logstash * fix some issues noticed when setting up e2e environment
- Loading branch information
Showing
15 changed files
with
2,096 additions
and
280 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
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 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 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,42 @@ | ||
/* eslint-disable require-jsdoc */ | ||
const Connection = require('./connection'); | ||
|
||
module.exports = class Manager { | ||
constructor(options, onError) { | ||
this.host = options.host || '127.0.0.1'; | ||
this.port = options.port || 28777; | ||
this.connectionStarted = false; | ||
this.logQueue = []; | ||
|
||
if (options.ssl_enable) { | ||
this.connection = new Connection.SecureConnection(options, onError); | ||
} else { | ||
this.connection = new Connection.PlainConnection(options, onError); | ||
} | ||
} | ||
|
||
start() { | ||
if (!this.connectionStarted) { | ||
this.connection.connect(this.flush.bind(this)); | ||
this.connectionStarted = true; | ||
} | ||
} | ||
|
||
log(entry, callback) { | ||
this.logQueue.push([entry, callback]); | ||
process.nextTick(this.flush.bind(this)); | ||
} | ||
|
||
close() { | ||
this.flush(); | ||
this.connection.close(); | ||
} | ||
|
||
flush() { | ||
while (this.connection.readyToSend() && this.logQueue.length) { | ||
const [entry, callback] = this.logQueue.shift(); | ||
this.connection.send(entry + '\n'); | ||
callback(); | ||
} | ||
} | ||
}; |
Oops, something went wrong.