You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 22, 2020. It is now read-only.
Out of curiosity, what's the advantage of doing something like:
type plugin struct {
API func() (gcloud.API, error)
flavorPlugins group_plugin.FlavorPluginLookup
groups map[group.ID]settings
lock sync.Mutex
}
// NewGCEGroupPlugin creates a new GCE group plugin for a given project
// and zone.
func NewGCEGroupPlugin(project, zone string, flavorPlugins group_plugin.FlavorPluginLookup) group.Plugin {
_, err := gcloud.New(project, zone)
if err != nil {
log.Fatal(err)
}
return &plugin{
API: func() (gcloud.API, error) {
return gcloud.New(project, zone)
},
flavorPlugins: flavorPlugins,
groups: map[group.ID]settings{},
}
}
and creating an actual client later on, instead of doing something like this:
type plugin struct {
API gcloud.API
flavorPlugins group_plugin.FlavorPluginLookup
groups map[group.ID]settings
lock sync.Mutex
}
// NewGCEGroupPlugin creates a new GCE group plugin for a given project
// and zone.
func NewGCEGroupPlugin(project, zone string, flavorPlugins group_plugin.FlavorPluginLookup) group.Plugin {
api, err := gcloud.New(project, zone)
if err != nil {
log.Fatal(err)
}
return &plugin{
API: api,
flavorPlugins: flavorPlugins,
groups: map[group.ID]settings{},
}
}
@FrenchBen we cannot keep a gcloud API for the whole lifetime of this plugin. So API is a factory that creates a new gcloud.API each time. In NewGCEGroupPlugin, we create create an gcloud.API instance to check that everything is well configured.
What I can do to improve the code is move this mechanism to the gcloud package.
This would help better scale a group of cattle.
The text was updated successfully, but these errors were encountered: