-
Notifications
You must be signed in to change notification settings - Fork 50
/
libstorage.go
71 lines (56 loc) · 2.25 KB
/
libstorage.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
Package libstorage provides a vendor agnostic storage orchestration model, API,
and reference client and server implementations. libStorage enables storage
consumption by leveraging methods commonly available, locally and/or externally,
to an operating system (OS).
The Past
The libStorage project and its architecture represents a culmination of
experience gained from the project authors' building of
several (http://bit.ly/1HIAet6) different storage (http://bit.ly/1Ya9Uft)
orchestration tools (https://github.com/codedellemc/rexray). While created using
different languages and targeting disparate storage platforms, all the tools
were architecturally aligned and embedded functionality directly inside the
tools and affected storage platforms.
This shared design goal enabled tools that natively consumed storage, sans
external dependencies.
The Present
Today libStorage focuses on adding value to container runtimes and storage
orchestration tools such as Docker and Mesos, however the libStorage
framework is available abstractly for more general usage across:
* Operating systems
* Storage platforms
* Hardware platforms
* Virtualization platforms
The client side implementation, focused on operating system activities,
has a minimal set of dependencies in order to avoid a large, runtime footprint.
*/
package libstorage
import (
"golang.org/x/net/context"
gofig "github.com/akutz/gofig/types"
"github.com/codedellemc/libstorage/api/server"
"github.com/codedellemc/libstorage/api/types"
"github.com/codedellemc/libstorage/client"
)
// New starts an embedded libStorage server and returns both the server
// instnace as well as a client connected to said instnace.
//
// While a new server may be launched, it's still up to the caller to provide
// a config instance with the correct properties to specify service
// information for a libStorage server.
func New(
ctx context.Context,
config gofig.Config) (types.Client, types.Server, <-chan error, error) {
s, errs, err := server.Serve(ctx, config)
if err != nil {
return nil, nil, nil, err
}
if h := config.GetString(types.ConfigHost); h == "" {
config.Set(types.ConfigHost, s.Addrs()[0])
}
c, err := client.New(ctx, config)
if err != nil {
return nil, nil, nil, err
}
return c, s, errs, nil
}