mhart / kinesalite

An implementation of Amazon's Kinesis built on LevelDB
MIT License
808 stars 86 forks source link

Update documented example as region is required #22

Closed scaleupcto closed 8 years ago

scaleupcto commented 8 years ago

Example code:

    var kinesalite = require('kinesalite'),
        kinesaliteServer = kinesalite({path: './mydb', createStreamMs: 50});

    kinesaliteServer.listen(4567, function(err) {
        if (err) {
            console.log(err);
            throw err;
        } else {
            console.log('Kinesalite started on port 4567');

            var AWS = require('aws-sdk');
            var kinesis = new AWS.Kinesis({endpoint: 'http://localhost:4567'});

            kinesis.listStreams(function(err,data) {
                if (err) {
                    console.log("Error listing streams");
                    console.log(err);
                } else {
                    console.log(data);
                }
            });
        }
    });

Console output:

Kinesalite started on port 4567
[AWS kinesis undefined 0.002s 0 retries] listStreams({})
Error listing streams
message=Missing region in config, code=ConfigError, time=Mon Dec 14 2015 19:12:08 GMT+0000 (GMT)

I've read in the closed issues about similar people having the same issue but it seems I am following your example and the Amazon SDK here (@2.2.9)

mhart commented 8 years ago

I think this is an error being thrown by the SDK, not kinesalite, no?

mhart commented 8 years ago

If you do new AWS.Kinesis({endpoint: 'http://localhost:4567', region: 'us-east-1'}) and it works, then I'll update the README. It may just work on my machine because I have a region already saved in ~/.aws/config

evansolomon commented 8 years ago

Not sure if it's required (seems like it is) but the listStreams documentation suggests the signature is params, callback, not just callback.

mhart commented 8 years ago

@evansolomon I doubt it – most SDK functions use a default set of params if you don't provide them.

mhart commented 8 years ago

Basically, @robotrobot – if you're using any of the AWS SDKs, you need to configure them before you make any calls, there's more info on that here: http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html

scaleupcto commented 8 years ago

@mhart the region is required, this worked for me:

{endpoint: 'http://localhost:4567', region: 'eu-west-1'}

scaleupcto commented 8 years ago

I have renamed the issue to reflect the bug with the docs ;-)

scaleupcto commented 8 years ago

Quick PR on docs: https://github.com/mhart/kinesalite/pull/23

Thanks for the library, really useful for our dev environments when working with kinesis.

mhart commented 8 years ago

@robotrobot the region is only necessary if you haven't setup your AWS config as the docs describe. Unless you have a bunch of different services in different regions (which is not typically the default), then it's definitely more work to be setting the region on a per-service basis.

I'll update the README to link to the AWS docs in case people haven't seen them.

Thanks for the issue and PR!