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

@@ -23,7 +23,7 @@ type MySQL struct {
credsutil.CredentialsProducer
}
func New() *MySQL {
func New() (interface{}, error) {
connProducer := &connutil.SQLConnectionProducer{}
connProducer.Type = mySQLTypeName
@@ -37,14 +37,17 @@ func New() *MySQL {
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.(*MySQL))
return nil
}

View File

@@ -66,7 +66,8 @@ func TestMySQL_Initialize(t *testing.T) {
"connection_url": connURL,
}
db := New()
dbRaw, _ := New()
db := dbRaw.(*MySQL)
connProducer := db.ConnectionProducer.(*connutil.SQLConnectionProducer)
err := db.Initialize(connectionDetails, true)
@@ -92,7 +93,8 @@ func TestMySQL_CreateUser(t *testing.T) {
"connection_url": connURL,
}
db := New()
dbRaw, _ := New()
db := dbRaw.(*MySQL)
err := db.Initialize(connectionDetails, true)
if err != nil {
@@ -127,7 +129,8 @@ func TestMySQL_RevokeUser(t *testing.T) {
"connection_url": connURL,
}
db := New()
dbRaw, _ := New()
db := dbRaw.(*MySQL)
err := db.Initialize(connectionDetails, true)
if err != nil {