{"bugs":{"url":"https://github.com/nlf/riakpbc/issues"},"_id":"riakpbc@1.0.3","homepage":"https://github.com/nlf/riakpbc","dist":{"tarball":"http://registry-npm.ywwl.com/riakpbc/download/riakpbc-1.0.3.tgz","shasum":"7977236780be81c01a9e524e9b5b5d2906b1d0a1","integrity":"sha512-rXI4etogAUVKg2xjkkAWRHRLCRvPHzZmGbUjWeA8IsXvg03G8EjCVNd8xOo4lB5OPRZBwoPgKQjzJjCxaDPP1A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCNc7/MJVkm4V9UUDgroqhfGx2m2lHjZwryY7MRJLxIPAIgPIBgXqhCAZ800PlePX2HFhMVN6kY3vqgme0tvHuHi1s="}],"size":13464,"noattachment":false,"key":"/riakpbc/-/riakpbc-1.0.3.tgz"},"_npmVersion":"1.3.14","description":"RiakPBC is a low-level Riak 1.4 proto buffer client.","license":"MIT","keywords":["riak","pbc","protobuf"],"directories":{},"_npmUser":{"name":"nisaacson","email":"noah+npmjs@nisaacson.com"},"devDependencies":{"async":"~0.2.9","nodeunit":"","q":"~0.9.7","chai":"~1.8.1","sinon":"~1.7.3"},"scripts":{"test":"node test"},"dependencies":{"protobuf.js":">=0.0.19","butils":"0.0.5","through":"~2.3.4"},"author":{"url":"https://github.com/nlf","email":"quitlahok@gmail.com","name":"Nathan"},"engines":{"node":">= 0.10.0 < 0.11"},"version":"1.0.3","main":"index.js","_from":".","maintainers":[{"name":"nlf","email":"quitlahok@gmail.com"},{"name":"troy","email":"troy@troy.io"},{"name":"nisaacson","email":"noah+npmjs@nisaacson.com"}],"name":"riakpbc","repository":{"type":"git","url":"git://github.com:nlf/riakpbc.git"},"readme":"# RiakPBC [![build status](http://img.shields.io/travis/nlf/riakpbc/master.svg?style=flat-square)](http://travis-ci.org/nlf/riakpbc)[![Code Climate](http://img.shields.io/codeclimate/github/nlf/riakpbc.svg?style=flat-square)](https://codeclimate.com/github/nlf/riakpbc)\n\nRiakPBC is a low-level [riak 2.0](http://basho.com/riak) [protocol buffer](https://developers.google.com/protocol-buffers/docs/overview) client for [node.js](http://nodejs.org/).\n\n# Contents\n- [Installation](#installation)\n- [Client](#client)\n  - [Options](#options)\n- [Usage](#usage)\n- [Data Conversions](#data-conversions)\n  - [bytes](#bytes)\n  - [uint32/float](#uint32float)\n  - [sint64](#sint64)\n  - [enums](#enums)\n  - [Embedded Messages](#embedded-messages)\n- [License](#license)\n\n\n## Installation\n\n```bash\nnpm install --save riakpbc\n```\n\n## Client\n\n```javascript\nvar RiakPBC = require('riakpbc');\nvar client = RiakPBC.createClient(/* options */);\n```\n\n### Options\n\nThe `options` object accepts the following parameters:\n\n- `connectTimeout`: The timeout (in milliseconds) for creating a new connection. (Default: `1000`)\n- `idleTimeout`: The amount of time (in milliseconds) that a node can be idle in the connection pool before it is released. (Default: `30000`)\n- `maxLifetime`: The amount of time (in milliseconds) that a node is used in the connection pool before it is released, regardless of activity. (Default: `Infinity`)\n- `minConnections`: The minimum number of connections to keep active in the connection pool. (Default: `0`)\n- `maxConnections`: The maximum number of connections that may be active in the connection pool at any given time. (Default: `10`)\n- `parseValues`: If set to `false`, values will be returned as buffers rather than strings or parsed JSON. (Default: `true`)\n- `nodes`: An array of `{ host: 'string', port: number }` objects specifying all of the riak nodes to use. These are then load balanced via round-robin.\n- `host`: If only connecting to a single node, you may specify the `host` property directly rather than passing an array of `nodes`. (Default: `'127.0.0.1'`)\n- `port`: Again, if only connecting to a single node, you may specify the `port` directly. (Default: `8087`)\n- `auth`: User and password, specified as a `{ user: 'string', password: 'string' }` object, to use for authentication if using [riak security](http://docs.basho.com/riak/latest/ops/running/authz/).\n\n## Usage\n\nFor a full reference of all available methods, see the [API Reference](doc/API.md).\n\nMethods that accept input have the signature `(params, callback)`, where `params` is an object containing the message to be sent to riak.\n\nMethods that do not accept input have the signature `(callback)`.\n\nCallbacks have the signature `(err, response)`.\n\nIf an error occurs, the `err` object will be a standard `Error` object wrapping the riak supplied [RpbErrorResp](doc/Messages.md#rpberrorresp) message.\n\nIf the call was successful, `response` will be the riak supplied message. Many calls do not return a value, or only return a value when certain flags are set, in these cases the `response` will be an empty object `{}`.\n\n```javascript\nclient.ping(function (err, response) {\n  if (err) {\n    return console.error('Failed to ping:', err);\n  }\n\n  console.log(response); // {}\n});\n```\n\nNote that callbacks are always optional, and if not supplied the call will return a stream instead.\n\nThese streams will emit only an `error` event if an error occurs. If the call is successful, the stream will emit one or more `data` events and an `end` event.\n```javascript\nvar keys = client.getKeys({ bucket: 'test' });\n\nkeys.on('error', function (err) {\n  console.error('An error occurred:', err);\n});\n\nkeys.on('data', function (response) {\n  console.log('Got some keys:', response.keys); // this could fire multiple times\n});\n\nkeys.on('end', function () {\n  console.log('Finished listing keys');\n});\n```\n\n## Data Conversions\n\nRiakPBC attempts to stay as accurate as possible when converting data to and from protocol buffer encoding.\n\nAll available messages are documented in the [Messages reference](doc/Messages.md).\n\nThe primary data types that riak uses are handled as follows:\n\n### bytes\n\nThe `bytes` type may be supplied as either a `string` or a `Buffer`.\n\nBy default, when translating a response message these fields will be converted to a `string` unless they are the `vclock` or `context` properties. Since these values are intended to be binary only, they are left as a `Buffer`.\n\nIn the case of [RpbContent](doc/Messages.md#rpbcontent) values, RiakPBC will convert the `value` field to a string only if a `content_type` was set, and begins with the string `text` (as in `text/plain` or `text/xml`). In addition, if `content_type` is set to `application/json` RiakPBC will parse the value as JSON automatically.\n\nThis behavior can be overridden and `Buffer` objects returned for all `bytes` fields by setting `{ parseValues: false }` in your client options.\n\n### uint32/float\n\nThese fields will always be treated as a plain javascript number.\n\n### sint64\n\nSince javascript does not properly handle 64 bit numbers, these are a special case.\n\nWhen used as input, you may pass either a number (`42`), a string (`'-98549321293'`), or a [long.js](https://github.com/dcodeIO/Long.js) object.\n\nIn a reply, you will always receive a [long.js](https://github.com/dcodeIO/Long.js) object. These objects allow RiakPBC to properly support real 64 bit number values.\n\n### bool\n\nThese fields will always be treated as a plain javascript boolean (i.e. `true` or `false`).\n\n### enums\n\nSeveral messages accept an enum field. RiakPBC exports these as variables on the main object to simplify input. They are as follows:\n\n- IndexQueryType:\n  - RiakPBC.IndexType.Exact\n  - RiakPBC.IndexType.Range\n- DataType:\n  - RiakPBC.DataType.Counter\n  - RiakPBC.DataType.Set\n  - RiakPBC.DataType.Map\n- MapFieldType:\n  - RiakPBC.FieldType.Counter\n  - RiakPBC.FieldType.Set\n  - RiakPBC.FieldType.Register\n  - RiakPBC.FieldType.Flag\n  - RiakPBC.FieldType.Map\n- FlagOp:\n  - RiakPBC.Flag.Enable\n  - RiakPBC.Flag.Disable\n\nThese variables are all simple numbers, however, so when RiakPBC returns a message containing one of these types you will receive a plain number. I would recommend using the exported variables for comparison purposes to maintain readable code.\n\n### Embedded Messages\n\nAll other types not documented here are an embedded message and are recursively encoded/decoded in the same fashion as the above types.\n\n## License\n\n[The MIT License (MIT)](https://raw.githubusercontent.com/nlf/riakpbc/master/LICENSE)\n","publish_time":1386226245004,"_cnpm_publish_time":1386226245004,"dist-tags":{"beta":"2.0.0-rc1","latest":"2.1.0"}}