Skip to content

Commit

Permalink
Merge pull request #207 from mfenniak/rethinkdb_2.0
Browse files Browse the repository at this point in the history
Compatibility with RethinkDB 2.0
  • Loading branch information
mfenniak committed Apr 14, 2015
2 parents 2f2f4d2 + 62ef11d commit 5b8370b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies:
- source /etc/lsb-release && echo "deb http://download.rethinkdb.com/apt $DISTRIB_CODENAME main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
- wget -qO- http://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -
- sudo apt-get update
- sudo apt-get install rethinkdb=1.16.3~0precise
- sudo apt-get install rethinkdb=2.0.0+1~0precise

test:
override:
Expand Down
6 changes: 6 additions & 0 deletions rethinkdb-net/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,12 @@ public async Task Dispose(CancellationToken cancellationToken)

switch (response.type)
{
case Response.ResponseType.SUCCESS_SEQUENCE:
// We're getting SUCCESS_SEQUENCE on the STOP since RethinkDB 2.0 of changes queries. Last
// records of the change stream that were pending to be sent to us, perhaps? Since this
// enumerator is being disposed, we're not going to return them. But this suggests we might
// need a "StopStreaming" method, after which we could read the last values, and then dispose
// the enumerator.
case Response.ResponseType.SUCCESS_ATOM:
break;
case Response.ResponseType.CLIENT_ERROR:
Expand Down
13 changes: 12 additions & 1 deletion rethinkdb-net/Protocols/Version_0_3_JsonProtocol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private Response ReadJsonResponse(JsonReader json, long token, ILogger logger)
if (json.CurrentToken == JsonToken.ObjectEnd)
break;
if (json.CurrentToken != JsonToken.MemberName)
throw new RethinkDbInternalErrorException("Unexpected JSON state");
throw new RethinkDbInternalErrorException(String.Format("Unexpected JSON state; expected MemberName, but was {0}", json.CurrentToken));

string property = (string)json.CurrentTokenValue;
if (property == "t")
Expand All @@ -216,14 +216,25 @@ private Response ReadJsonResponse(JsonReader json, long token, ILogger logger)
else if (property == "b")
retval.backtrace = ReadBacktrace(json);
else if (property == "p")
{
logger.Warning("Profiling is not currently supported by rethinkdb-net; profiling data will be discarded");
DiscardNextJsonValue(json); // read the value so that the reader isn't sitting at the unexpected property's vaue
}
else
{
logger.Information("Unexpected property {0} in JSON response; ignoring", property);
DiscardNextJsonValue(json); // read the value so that the reader isn't sitting at the unexpected property's vaue
}
}

return retval;
}

private void DiscardNextJsonValue(JsonReader json)
{
ReadDatum(json);
}

private static Response.ResponseType ReadResponseType(JsonReader json)
{
if (!json.Read())
Expand Down

0 comments on commit 5b8370b

Please sign in to comment.