Calls to builtin plugins now go directly to the implementation instead of go-plugin

This commit is contained in:
Brian Kassouf
2017-04-20 18:46:41 -07:00
parent d9ce189b33
commit f1fa617e03
13 changed files with 94 additions and 179 deletions

View File

@@ -16,7 +16,8 @@ import (
const postgreSQLTypeName string = "postgres"
func New() *PostgreSQL {
// New implements builtinplugins.BuiltinFactory
func New() (interface{}, error) {
connProducer := &connutil.SQLConnectionProducer{}
connProducer.Type = postgreSQLTypeName
@@ -30,14 +31,17 @@ func New() *PostgreSQL {
CredentialsProducer: credsProducer,
}
return dbType
return dbType, nil
}
// Run instatiates a PostgreSQL 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.(*PostgreSQL))
return nil
}

View File

@@ -66,7 +66,9 @@ func TestPostgreSQL_Initialize(t *testing.T) {
"connection_url": connURL,
}
db := New()
dbRaw, _ := New()
db := dbRaw.(*PostgreSQL)
connProducer := db.ConnectionProducer.(*connutil.SQLConnectionProducer)
err := db.Initialize(connectionDetails, true)
@@ -92,7 +94,8 @@ func TestPostgreSQL_CreateUser(t *testing.T) {
"connection_url": connURL,
}
db := New()
dbRaw, _ := New()
db := dbRaw.(*PostgreSQL)
err := db.Initialize(connectionDetails, true)
if err != nil {
t.Fatalf("err: %s", err)
@@ -136,7 +139,8 @@ func TestPostgreSQL_RenewUser(t *testing.T) {
"connection_url": connURL,
}
db := New()
dbRaw, _ := New()
db := dbRaw.(*PostgreSQL)
err := db.Initialize(connectionDetails, true)
if err != nil {
t.Fatalf("err: %s", err)
@@ -176,7 +180,8 @@ func TestPostgreSQL_RevokeUser(t *testing.T) {
"connection_url": connURL,
}
db := New()
dbRaw, _ := New()
db := dbRaw.(*PostgreSQL)
err := db.Initialize(connectionDetails, true)
if err != nil {
t.Fatalf("err: %s", err)