forked from rexray/rexray
-
Notifications
You must be signed in to change notification settings - Fork 1
/
drivers.go
41 lines (34 loc) · 900 Bytes
/
drivers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package core
var (
driverCtors map[string]NewDriver
)
func initDrivers() {
driverCtors = map[string]NewDriver{}
}
// Driver represents a REX-Ray driver.
type Driver interface {
// The name of the driver.
Name() string
// Init initalizes the driver so that it is in a state to communicate to
// its underlying platform / storage provider.
Init(rexray *RexRay) error
}
// NewDriver is a function that constructs a new driver.
type NewDriver func() Driver
// RegisterDriver is used by drivers to notify the driver manager of their
// availability to be used.
func RegisterDriver(driverName string, ctor NewDriver) {
driverCtors[driverName] = ctor
}
// DriverNames returns a channel which receives the names of all of the
// registerd drivers.
func DriverNames() <-chan string {
c := make(chan string)
go func() {
for n := range driverCtors {
c <- n
}
close(c)
}()
return c
}