Introduce dynamic plugins

go1.8 Plugin package brings a mechanism for dynamyc loading.
StorageDriver or AccessController can be compiled as plugin
and can be loaded at runtime.

Signed-off-by: Anton Tiurin <noxiouz@yandex.ru>
This commit is contained in:
Anton Tiurin
2017-01-20 14:20:52 +03:00
parent beabc206e1
commit 9b1e893755
13 changed files with 214 additions and 10 deletions

View File

@@ -198,5 +198,14 @@ func GetAccessController(name string, options map[string]interface{}) (AccessCon
return initFunc(options)
}
return nil, fmt.Errorf("no access controller registered with name: %s", name)
return nil, InvalidAccessControllerError{name}
}
// InvalidAccessControllerError records an attempt to construct an unregistered storage driver
type InvalidAccessControllerError struct {
Name string
}
func (err InvalidAccessControllerError) Error() string {
return fmt.Sprintf("no access controller registered with name: %s", err.Name)
}