Skip to content

Commit 81d9745

Browse files
committed
Merge branch 'master' into mm-protocol-buffers-merge-master
Conflicts: README.md
2 parents a708cd3 + 6a2c599 commit 81d9745

File tree

10 files changed

+62
-16
lines changed

10 files changed

+62
-16
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
language: node_js
22
node_js:
3-
- 0.8
3+
- "0.8"
4+
- "0.10"
45
services:
56
- riak
67
script:

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# riak-js
22

3-
[Node.js](http://nodejs.org/) client for [Riak](http://riak.basho.com).
3+
[Node.js](http://nodejs.org/) client for [Riak](http://basho.com/riak/).
44

5-
[![Build Status](https://secure.travis-ci.org/mostlyserious/riak-js.png?branch=js)](https://travis-ci.org/mostlyserious/riak-js)
5+
[![Build Status](https://secure.travis-ci.org/mostlyserious/riak-js.png?branch=master)](https://travis-ci.org/mostlyserious/riak-js)
66

77
### Installation
88

@@ -16,10 +16,16 @@ Follow updates on Twitter: [@riakjs](http://twitter.com/riakjs)
1616

1717
### Changelog
1818

19-
#### 0.9.4pre3
19+
#### 0.10.0 (dev)
2020

21-
- Preliminary support for Protocol Buffers. Still missing is streaming
22-
MapReduce and streaming key fetching.
21+
- Preliminary support for Protocol Buffers via a single connection.
22+
- Fetch siblings by default, restoring previous riak-js behavior
23+
- Populate meta.links when saving an object based on the response's HTTP
24+
headers (github.com/accelerated)
25+
- Fix content length override. Allows handing in streaming data from e.g.
26+
connect.js. (github.com/englercj)
27+
- Only set the language attribute on map and reduce phases. Avoid setting it on
28+
phases where it's not according to spec. (github.com/accelerated)
2329

2430
#### 0.9.3
2531

lib/http-meta.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ HttpMeta.prototype.loadResponse = function(response) {
3232
this.statusCode = response.statusCode;
3333

3434
// links
35-
this.links = linkUtils.stringToLinks(headers.link);
35+
if (headers.link){
36+
this.links = linkUtils.stringToLinks(headers.link);
37+
} else if (response.client !== undefined && response.client._httpMessage._headers.link) {
38+
this.links = linkUtils.stringToLinks(response.client._httpMessage._headers.link);
39+
}
3640

3741
// etag -- replace any quotes in the string
3842
if (headers.etag) this.etag = headers.etag.replace(/"/g, '');
@@ -99,7 +103,7 @@ Object.defineProperty(HttpMeta.prototype, 'headers', {
99103
if (this.data.length) length = String(this.data.length);
100104
}
101105

102-
this._headers['Content-Length'] = length;
106+
if(!this.contentLength) this._headers['content-length'] = length;
103107
this._cacheHeaders = true; // headers cached
104108
return this._headers;
105109
},

lib/mapper.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ var makePhases = function(type, phase, args) {
8585
case 'object': if (p.source) p.source = p.source.toString(); temp[type] = p; break;
8686
}
8787

88-
temp[type].language = temp[type].language || Mapper.defaults.language;
88+
if (type == 'map' || type == 'reduce') {
89+
temp[type].language = temp[type].language || Mapper.defaults.language;
90+
}
8991
return temp;
9092
}
9193
});
@@ -98,4 +100,4 @@ Mapper.defaults = {
98100

99101
// exports
100102

101-
module.exports = Mapper;
103+
module.exports = Mapper;

lib/meta.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ Meta.defaults = {
145145
resource: 'riak',
146146
clientId: 'riak-js',
147147
contentEncoding: 'utf8',
148+
accept: 'multipart/mixed,application/json;q=0.7, */*;q=0.5',
148149
callback: function(err, data, meta) {
149150
},
150151

test/http-client-search-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('http-client-search-tests', function() {
4848
});
4949
});
5050

51-
it('Map/Reduce with saerch', function(done) {
51+
it('Map/Reduce with search', function(done) {
5252
db.mapreduce.search(bucket, 'email:test-search@gmail.com')
5353
.map('Riak.mapValuesJson')
5454
.run(function(err, data) {

test/http-client-siblings-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ describe('http-client-siblings-tests', function() {
99
before(function(done) {
1010
db = new HttpClient({
1111
port: 8098,
12-
accept: 'multipart/mixed,application/json;q=0.7, */*;q=0.5'
1312
});
1413

1514
// Ensure unit tests don't collide with pre-existing buckets

test/http-client-test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,20 @@ describe('http-client-tests', function() {
124124
});
125125
});
126126

127+
it('Populates the links when saving an object', function(done) {
128+
db.save(bucket, 'other@gmail.com',
129+
{ name: 'Other Dude' },
130+
{ links: [
131+
{ bucket: bucket, key: 'test@gmail.com' }
132+
]}, function(err, data, meta) {
133+
should.exist(meta.links);
134+
meta.links.should.have.length(1)
135+
136+
done();
137+
});
138+
139+
});
140+
127141
it('Fetch via Linkwalk', function(done) {
128142
db.walk(bucket, 'other@gmail.com', [
129143
{bucket: bucket}

test/http-meta-test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,15 @@ describe('http-meta-tests', function() {
6161
links: [
6262
{ bucket: 'test', key: 'doc%2$@', tag: 'next' }
6363
],
64-
headers: { Authorization: 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==', 'X-Riak-Meta-fire': 'yes' }
64+
headers: {
65+
Authorization: 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==',
66+
'content-length': '2687',
67+
'X-Riak-Meta-fire': 'yes'
68+
}
6569
});
6670

6771
should.not.exist(meta.headers.statusCode);
72+
meta.headers['content-length'].should.equal('2687');
6873
meta.headers['X-Riak-Meta-fire'].should.equal('yes');
6974
// meta.headers['Link'].should.equal('</riak/test/doc%252%24%40>; riaktag="next"'); -- not yet implemented
7075
meta.headers['Authorization'].should.equal('Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==');

test/mapper-test.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@ describe('mapper-tests', function() {
1212
});
1313

1414
it('Phases are added correctly', function(done) {
15-
1615
var mapper = new Mapper('airlines');
1716

1817
var job = mapper
1918
.map('Riak.mapValuesJson', 'abc')
20-
.link({ bucket: 'flights', keep: false, language: 'english' })
19+
.link({ bucket: 'flights', keep: false})
2120
.reduce(function() { return 1 + 1 });
2221

2322
job.phases.length.should.equal(3);
2423
job.phases[0].map.should.eql({ name: 'Riak.mapValuesJson', arg: 'abc', language: 'javascript' });
25-
job.phases[1].link.should.eql({ bucket: 'flights', keep: false, language: 'english' });
24+
job.phases[1].link.should.eql({ bucket: 'flights', keep: false});
2625
job.phases[2].reduce.source.should.equal('function () { return 1 + 1 }');
2726
job.phases[2].reduce.language.should.equal('javascript');
2827

@@ -31,4 +30,19 @@ describe('mapper-tests', function() {
3130

3231
done();
3332
});
33+
34+
it('Sets the language only on map and reduce phases', function(done) {
35+
var mapper = new Mapper('airlines');
36+
37+
var job = mapper
38+
.link({ bucket: 'flights', keep: false})
39+
.map('Riak.mapValuesJson', 'abc')
40+
.map({module: 'riak_js', function: 'mapvalues', language: 'erlang'})
41+
.reduce(function() { return 1 + 1 });
42+
should.not.exist(job.phases[0].link.language);
43+
job.phases[1].map.language.should.equal('javascript');
44+
job.phases[2].map.language.should.equal('erlang');
45+
job.phases[3].reduce.language.should.equal('javascript');
46+
done();
47+
});
3448
});

0 commit comments

Comments
 (0)