Skip to content

Commit

Permalink
Merge pull request #413 from akutz/feature/single-module-server
Browse files Browse the repository at this point in the history
Single Module Server
  • Loading branch information
akutz committed May 7, 2016
2 parents 6e258e5 + 59d1d39 commit f9c44bc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
12 changes: 1 addition & 11 deletions daemon/module/docker/volumedriver/voldriver.go
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/akutz/gofig"
"github.com/akutz/goof"
"github.com/akutz/gotil"
"github.com/emccode/libstorage"
"github.com/emccode/libstorage/api/context"
apitypes "github.com/emccode/libstorage/api/types"
apiutils "github.com/emccode/libstorage/api/utils"
Expand Down Expand Up @@ -83,6 +82,7 @@ func newModule(c *module.Config) (module.Module, error) {

return &mod{
ctx: ctx,
lsc: c.Client,
config: cc,
name: c.Name,
desc: c.Description,
Expand Down Expand Up @@ -113,16 +113,6 @@ type pluginRequest struct {

func (m *mod) Start() error {

lsc, _, err, _ := libstorage.New(m.config)

if err != nil {
for k, v := range m.config.AllSettings() {
log.Errorf("%s=%v", k, v)
}
log.Fatal(err)
}
m.lsc = lsc

proto, addr, parseAddrErr := gotil.ParseAddress(m.Address())
if parseAddrErr != nil {
return parseAddrErr
Expand Down
25 changes: 20 additions & 5 deletions daemon/module/module.go
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/akutz/gofig"
"github.com/akutz/goof"
"github.com/akutz/gotil"
"github.com/emccode/libstorage"
apitypes "github.com/emccode/libstorage/api/types"
)

// Module is the interface to which types adhere in order to participate as
Expand Down Expand Up @@ -55,11 +57,12 @@ func GetModOptVal(opts map[string]string, key string) string {

// Config is a struct used to configure a module.
type Config struct {
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
Address string `json:"address"`
Config gofig.Config `json:"config,omitempty"`
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
Address string `json:"address"`
Config gofig.Config `json:"config,omitempty"`
Client apitypes.Client `json:"-"`
}

// Type is a struct that describes a module type
Expand Down Expand Up @@ -158,12 +161,24 @@ func InitializeDefaultModules() error {
}
}

lsc, _, err, errs := libstorage.New(c)
if err != nil {
panic(err)
}
go func() {
err := <-errs
if err != nil {
panic(err)
}
}()

modConfigs, err := getConfiguredModules(c)
if err != nil {
return err
}

for _, mc := range modConfigs {
mc.Client = lsc
mod, err := InitializeModule(mc)
if err != nil {
return err
Expand Down

0 comments on commit f9c44bc

Please sign in to comment.