This repository has been archived by the owner on Feb 14, 2024. It is now read-only.
-
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.
- Loading branch information
0 parents
commit 272c0b6
Showing
10 changed files
with
634 additions
and
0 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,18 @@ | ||
# http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
max_line_length = 100 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
max_line_length = 0 | ||
trim_trailing_whitespace = false | ||
|
||
[COMMIT_EDITMSG] | ||
max_line_length = 0 |
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 @@ | ||
yarn.lock linguist-generated=true |
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,3 @@ | ||
node_modules | ||
|
||
*.log |
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,4 @@ | ||
{ | ||
"printWidth": 100, | ||
"singleQuote": true | ||
} |
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,3 @@ | ||
## 1.0.0 (July 4, 2019) | ||
|
||
Initial release! :tada: |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Neo Financial Technologies Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,22 @@ | ||
# Kinesis Logger | ||
|
||
Read from the specified Kinesis stream and log messages to the console. | ||
|
||
## Usage | ||
|
||
```txt | ||
kinesis-logger <name> [options] | ||
read from the specified kinesis stream | ||
Positionals: | ||
name the name of the kinesis stream [string] | ||
Options: | ||
--version Show version number [boolean] | ||
--region AWS region of kinesis stream | ||
[string] [required] [default: "us-west-2"] | ||
--offset number of seconds back in time to start reading from | ||
[number] [required] [default: 0] | ||
--help Show help [boolean] | ||
``` |
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,48 @@ | ||
const AWS = require('aws-sdk'); | ||
const { KinesisReadable } = require('kinesis-streams'); | ||
const { subSeconds } = require('date-fns'); | ||
const yargs = require('yargs'); | ||
|
||
const readStream = async args => { | ||
const client = new AWS.Kinesis({ region: args.region, maxRetries: 10 }); | ||
const timestamp = subSeconds(new Date(), args.offset); | ||
const reader = new KinesisReadable(client, args.name, { | ||
logger: console, | ||
parser: JSON.parse, | ||
ShardIteratorType: 'AT_TIMESTAMP', | ||
Timestamp: timestamp | ||
}); | ||
|
||
reader.on('data', data => { | ||
console.log(data); | ||
}); | ||
}; | ||
|
||
yargs | ||
.scriptName('kinesis-logger') | ||
.usage('$0 name [args]') | ||
.command({ | ||
command: '$0 <name> [options]', | ||
describe: 'read from the specified kinesis stream', | ||
builder: yargs => | ||
yargs.positional('name', { | ||
demandOption: true, | ||
describe: 'the name of the kinesis stream', | ||
type: 'string' | ||
}), | ||
handler: readStream | ||
}) | ||
.demandCommand(1) | ||
.option('region', { | ||
demandOption: true, | ||
default: 'us-west-2', | ||
describe: 'AWS region of kinesis stream', | ||
type: 'string' | ||
}) | ||
.option('offset', { | ||
demandOption: true, | ||
default: 0, | ||
describe: 'number of seconds back in time to start reading from', | ||
type: 'number' | ||
}) | ||
.help().argv; |
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,33 @@ | ||
{ | ||
"name": "kinesis-logger", | ||
"description": "Read from the specified Kinesis stream and log messages to the console", | ||
"version": "1.0.0", | ||
"author": "Neo Financial Engineering <[email protected]>", | ||
"main": "index.js", | ||
"bin": "index.js", | ||
"license": "MIT", | ||
"homepage": "https://github.com/neofinancial/kinesis-logger", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/neofinancial/kinesis-logger" | ||
}, | ||
"engines": { | ||
"node": "^8.10.0" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"aws", | ||
"kinesis", | ||
"stream", | ||
"javascript", | ||
"node" | ||
], | ||
"dependencies": { | ||
"aws-sdk": "^2.488.0", | ||
"date-fns": "^1.30.1", | ||
"kinesis-streams": "^0.12.0", | ||
"yargs": "^13.2.4" | ||
} | ||
} |
Oops, something went wrong.