Install Kinesalite via npm
masterInstall Kinesalite globally using npm to use the CLI tool.
$ npm install -g kinesaliterepository·master·Indexed 21 days ago
https://github.com/mhart/kinesaliteA local implementation of Amazon Kinesis built on LevelDB, providing a mock HTTP server for testing Kinesis-dependent applications. It supports a subset of the Kinesis API, including CreateStream, PutRecord, and GetRecords, and can be used via a CLI tool or programmatically as a Node.js module.
Install Kinesalite globally using npm to use the CLI tool.
$ npm install -g kinesaliteKinesalite handles requests using AWS-compatible serialization formats. It detects the format based on the Content-Type header. Supported types include:
application/x-amz-json-1.1 (Amazon JSON)application/x-amz-cbor-1.1 (Amazon CBOR)application/json (Standard JSON)Note: While application/json is accepted for parsing, the server logic specifically checks for the Amazon-specific headers to progress certain operations.
You can use the kinesis module to connect to Kinesalite. Note that this module currently only works in HTTPS mode, which requires starting Kinesalite with the --ssl flag.
var kinesis = require('kinesis')
kinesis.listStreams({host: 'localhost', port: 4567}, console.log)To interact with Kinesalite using the official aws-sdk, point the Kinesis client to the Kinesalite endpoint (e.g., http://localhost:4567). Ensure the SDK is configured before initializing the client.
var AWS = require('aws-sdk')
var kinesis = new AWS.Kinesis({endpoint: 'http://localhost:4567'})
kinesis.listStreams(console.log.bind(console))You can require kinesalite as a module to get a standard Node.js HTTP server instance. This allows you to configure the LevelDB path and stream state durations programmatically.
// Returns a standard Node.js HTTP server
var kinesalite = require('kinesalite'),
kinesaliteServer = kinesalite({path: './mydb', createStreamMs: 50})
// Listen on port 4567
kinesaliteServer.listen(4567, function(err) {
if (err) throw err
console.log('Kinesalite started on port 4567')
})The following options are available when running the kinesalite command:
| Option | Description |
|---|---|
--help | Display this help message and exit |
--port <port> | The port to listen on (default: 4567) |
--path <path> | The path to use for the LevelDB store (in-memory by default) |
--ssl | Enable SSL for the web server (default: false) |
--createStreamMs <ms> | Amount of time streams stay in CREATING state (default: 500) |
--deleteStreamMs <ms> | Amount of time streams stay in DELETING state (default: 500) |
--updateStreamMs <ms> | Amount of time streams stay in UPDATING state (default: 500) |
--shardLimit <limit> | Shard limit for error reporting (default: 10) |
Kinesalite can be run as a standalone HTTP server from the command line. It is an implementation of Amazon's Kinesis API backed by LevelDB.
$ kinesalite --help
Usage: kinesalite [--port <port>] [--path <path>] [--ssl] [options]The kinesalite(options) function is the primary entrypoint. It returns a standard Node.js http.Server or https.Server instance configured to emulate the Amazon Kinesis API.
To enable HTTPS, provide an options object containing SSL credentials. If options.ssl is true, the server will attempt to load default certificates from the ssl/ directory relative to the module if they are not explicitly provided in the options object.
When calling server.close(), Kinesalite ensures that the underlying database connection is also closed before completing the callback.
const kinesalite = require('kinesalite');
// Standard HTTP server
const server = kinesalite();
server.listen(4567);
// HTTPS server with custom certificates
const httpsServer = kinesalite({
ssl: true,
key: fs.readFileSync('path/to/server-key.pem'),
cert: fs.readFileSync('path/to/server-crt.pem'),
ca: fs.readFileSync('path/to/ca-crt.pem')
});
httpsServer.listen(4567);Kinesalite supports a specific subset of the Kinesis API. The following operations are implemented:
AddTagsToStreamCreateStreamDeleteStreamDescribeStreamDescribeStreamSummaryGetRecordsGetShardIteratorListShardsListStreamsListTagsForStreamMergeShardsPutRecordPutRecordsRemoveTagsFromStreamSplitShardIncreaseStreamRetentionPeriodDecreaseStreamRetentionPeriodKinesalite is a Kinesis HTTP server that can be optionally backed by LevelDB. You can run it from the command line to mock Kinesis functionality. By default, it listens on port 4567 and uses an in-memory store unless a --path is provided.
kinesalite [--port <port>] [--path <path>] [--ssl] [options]