-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#76] Protocol v3 & v4 support, serialization/deserialization rewrite using scodec #171
Conversation
How's this going? Are you at the Cassandra summit? Might be nice to review together |
Hi @chbatey, it's going pretty well! Existing tests are passing, what's left is adding additional tests in the codec module, adding additional tests for the new types and maybe some clean up. Hopefully I can complete that really soon. I'll be at the summit, I'd definitely be up for a review, that'd be fun! |
Rebased against master and added license headers. Working on finishing up tests in the codec module and updating rest of the code to support the v3/v4 types. I'll probably get that all going and clean up the commit history today. |
Busy man! |
rebased on master to get the |
Getting closer, completed adding the new types and failures. Going to spend some time tomorrow evening updating the docs. I'll then do some cleanup / optimization of the codec code and clean up the commit history. If all goes well should complete sometime this weekend. |
Use 'AnyMatch' as catch all Use terminate instead of shutdown.
Inline own implicit conversions. One small difference between this implementation and scodec-akka is this uses reflection instead of a java class.
Have collection-based data types consider protocol version for length. Batch considers protocol version for whether or not to include flags. Prepare considers protocol version for whether or not to include pks. native PF for encoding from Any -> Native type for data type. Use CL from statement only if prime does not include one.
There are enough changes here, some of which may be (unintentionally) breaking, bumping up the minor version seems like the right way to go here.
Also add example for priming a query with a pattern and some other cleanup.
Need to be able to differentiate when there are no columns and no column metadata was requested.
Also add documentation
Rename BadCredentials to AuthenticationError. Switch from scalaz for Memo to guava for Cache as would like to use a LRU cache for Row codecs since this could grow large if you have a lot of unique metadata.
I've spent some time the last few days adding integration tests for the new types and errors, and some more tests and documentation for the codec module. I think i've got everything worked out and this is ready aside from the commit history. @chbatey would you prefer I squash the commits now or would you have me leave it as is for now for review? |
Great work @tolbertam 👍 |
Taking a look this weekend |
spray-routing-shapeless2 depends on shapeless 2.1, where scodec depends on shapeless 2.3. Depending on what is being used for dependency resolution, if shapeless 2.1 is chosen over 2.3 this causes incompatibility issues with scodec.
private[this] def inspectProtocolVersion(input: ByteVector): Try[(ProtocolFlags, ByteVector)] = { | ||
next[ProtocolFlags](input).flatMap { | ||
case ((ProtocolFlags(_, UnsupportedProtocolVersion(v)), _)) => | ||
Failure(new UnsupportedProtocolException(v)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for new
val registerHandler = registerHandlerFactory(context) | ||
write(Ready, frame.header) | ||
context become initialized(queryHandler, batchHandler, registerHandler) | ||
case _ => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove braces to make it consistent with the other cases
case result: FatalResult => result.produceFatalError(connection) | ||
writePrime(execute, prime, header, Some(connection), alternative=Some(Reply(VoidResult)), consistency = Some(execute.parameters.consistency)) | ||
case None => | ||
var errMsg = s"Could not find prepared statement with id: 0x${execute.id.toHex}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be a val
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d'oh! I've been doing too much javascript lately 😄
writePrime(execute, prime, header, Some(connection), alternative=Some(Reply(VoidResult)), consistency = Some(execute.parameters.consistency)) | ||
case None => | ||
var errMsg = s"Could not find prepared statement with id: 0x${execute.id.toHex}" | ||
activityLog.recordPreparedStatementExecution(errMsg, execute.parameters.consistency, Nil, Nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i take it you found this useful for testing? just a little off we use an error msg as the statement text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrmm, I may be misunderstanding, isn't the behavior the same as before? I think the result is in this case that we record a prepared statement execution with the error message as the query text, and then an Unprepared message gets sent back to the client which will cause most drivers to repreare the statement.
Happy to merge this whenever. I'll be adding some features shortly |
Excellent, thanks for the review! I'll address your feedback this morning. |
added commit for review feedback, thanks! Would you like me to do anything with the commit history, or would you just prefer to squash the whole thing on merge? |
Squashing into one if find! It has been a long time since I looked at Scala lol |
Just remembered, when it comes time to do a release with these changes, there are a few activites:
|
Thanks @tolbertam |
@chbatey would you like me to merge and go through the process to release this? Can do it tomorrow if you like. |
Go for it!
… On 10 Jan 2017, at 21:02, Andrew Tolbert ***@***.***> wrote:
@chbatey would you like me to merge and go through the process to release this? Can do it tomorrow if you like.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Awesome, thanks! Will take care of that this evening :) |
For #76, Adds protocol v3 and v4 support. This is a work in progress, but it's functional and currently all tests pass.
Summary of the major changes:
codec
module with scodec being the only dependency.prime
member on theThen
implementations to convert the inputs to aPrime
.There should be no functional changes for users with one slight exception. Previously if no Prime is found for a query, query parameters would not be recorded in the activity log for batch and prepared statements. Now it records the query parameters as if they were varchars. There may also be some small nuances in conversions from json strings/numbers/booleans/etc. into the native type for a given data type, but i haven't identified any yet.
What is remaining: