Skip to content

Commit

Permalink
Update New() func signature and its references
Browse files Browse the repository at this point in the history
  • Loading branch information
calvn committed Apr 27, 2017
1 parent 2faa08d commit 230a36c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
11 changes: 7 additions & 4 deletions plugins/database/cassandra/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Cassandra struct {
credsutil.CredentialsProducer
}

func New() *Cassandra {
func New() (interface{}, error) {
connProducer := &connutil.CassandraConnectionProducer{}
connProducer.Type = cassandraTypeName

Expand All @@ -35,14 +35,17 @@ func New() *Cassandra {
CredentialsProducer: credsProducer,
}

return dbType
return dbType, nil
}

// Run instantiates a MySQL object, and runs the RPC server for the plugin
func Run() error {
dbType := New()
dbType, err := New()
if err != nil {
return err
}

dbplugin.NewPluginServer(dbType)
dbplugin.NewPluginServer(dbType.(*Cassandra))

return nil
}
Expand Down
12 changes: 8 additions & 4 deletions plugins/database/cassandra/cassandra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ func TestCassandra_Initialize(t *testing.T) {
"protocol_version": 4,
}

db := New()
dbRaw, _ := New()
db := dbRaw.(*Cassandra)
connProducer := db.ConnectionProducer.(*connutil.CassandraConnectionProducer)

err := db.Initialize(connectionDetails, true)
Expand Down Expand Up @@ -109,7 +110,8 @@ func TestCassandra_CreateUser(t *testing.T) {
"protocol_version": 4,
}

db := New()
dbRaw, _ := New()
db := dbRaw.(*Cassandra)
err := db.Initialize(connectionDetails, true)
if err != nil {
t.Fatalf("err: %s", err)
Expand Down Expand Up @@ -140,7 +142,8 @@ func TestMyCassandra_RenewUser(t *testing.T) {
"protocol_version": 4,
}

db := New()
dbRaw, _ := New()
db := dbRaw.(*Cassandra)
err := db.Initialize(connectionDetails, true)
if err != nil {
t.Fatalf("err: %s", err)
Expand Down Expand Up @@ -176,7 +179,8 @@ func TestCassandra_RevokeUser(t *testing.T) {
"protocol_version": 4,
}

db := New()
dbRaw, _ := New()
db := dbRaw.(*Cassandra)
err := db.Initialize(connectionDetails, true)
if err != nil {
t.Fatalf("err: %s", err)
Expand Down

0 comments on commit 230a36c

Please sign in to comment.