scylladb / scylla-go-driver

Experimental, high performance Scylla Driver, University of Warsaw students' project
Apache License 2.0
151 stars 7 forks source link

Drop-in replacement for gocql #296

Open Kulezi opened 2 years ago

Kulezi commented 2 years ago

GoCQL drop-in replacement

The goal of this pull request is to provide a gocql module inside the scylla-go-driver repository that could be used as a drop-in replacement for gocql, just by using a replace directive in go.mod like this: replace github.com/gocql/gocql => github.com/scylladb/scylla-go-driver/gocql <version/commit>

Benefits

Features: ORM, query building and migrations support can be used just by replacing GoCQL with the new driver in https://github.com/scylladb/gocqlx Tests: Existing integration tests for GoCQLX, Scylla Manager, Scylla Operator, etc. can be used to test drivers correctness and safety.

Tests

New gocql package was tested against GocqlX and Scylla Manager tests. GocqlX and Scylla Manager tests pass with exceptions:

To pass the Scylla Manager tests its also needed to add two lines of code to the manager tests as gocql and the new driver return different error messages on unauthorised errors.

Changes

This PR makes many small changes mostly to the driver's API so it can provide a gocql compatible API in the gocql package, those chages include:

gocql package

This PR features a new gocql package, wrapping Session, Query and Iter in structs exporting gocql API methods. Base functionality is here, some missing gocql features are:

viggin543 commented 1 year ago

can't wait to try it :)