Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Builds with single backend #528

Closed
colinmollenhour opened this issue Feb 6, 2017 · 2 comments
Closed

Builds with single backend #528

colinmollenhour opened this issue Feb 6, 2017 · 2 comments

Comments

@colinmollenhour
Copy link

Would it be hard to create custom builds that don't have every supported backend built in? The binary is getting quite large and grows with each new backend added. With a single backend like etcd it would probably be quite small though. Even if the binaries weren't published it would be nice if there was a simple way (and instructions) to make your own build.

@HeavyHorst
Copy link
Contributor

replace the file "backends/client.go" with the following code (for etcd only).

  1 package backends
  2
  3 import (
  4     "errors"
  5     "strings"
  6
  7     "github.com/kelseyhightower/confd/backends/etcd"
  8     "github.com/kelseyhightower/confd/log"
  9 )
 10
 11 // The StoreClient interface is implemented by objects that can retrieve
 12 // key/value pairs from a backend store.
 13 type StoreClient interface {
 14     GetValues(keys []string) (map[string]string, error)
 15     WatchPrefix(prefix string, keys []string, waitIndex uint64, stopChan chan bool) (uint64, error)
 16 }
 17
 18 // New is used to create a storage client based on our configuration.
 19 func New(config Config) (StoreClient, error) {
 20     if config.Backend == "" {
 21         config.Backend = "etcd"
 22     }
 23     backendNodes := config.BackendNodes
 24     log.Info("Backend nodes set to " + strings.Join(backendNodes, ", "))
 25     switch config.Backend {
 26     case "etcd":
 27         // Create the etcd client upfront and use it for the life of the process.
 28         // The etcdClient is an http.Client and designed to be reused.
 29         return etcd.NewEtcdClient(backendNodes, config.ClientCert, config.ClientKey, config.ClientCaKeys, config.BasicAuth, config.Username, config.Password)
 30     }
 31     return nil, errors.New("Invalid backend")
 32 }

@colinmollenhour
Copy link
Author

Hmm, I tried to build one with just env, etcd and redis support and the binary is still 18M so I guess the savings are really not what I expected.. Probably not worthwhile then. Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants