Merge pull request #787 from aluzzardi/store-options-as-ptr

pkg/store: Pass Options as pointer, not value.
This commit is contained in:
Alexandre Beslic 2015-05-13 23:09:37 -07:00
commit 9d68cc0506
5 changed files with 6 additions and 12 deletions

View File

@ -49,7 +49,7 @@ func (s *Discovery) Initialize(uris string, heartbeat uint64) error {
s.store, err = store.CreateStore(
s.name, // name of the store
addrs,
store.Config{
&store.Config{
Timeout: s.heartbeat,
},
)

View File

@ -2,7 +2,6 @@ package store
import (
"crypto/tls"
"errors"
"net/http"
"time"
@ -10,11 +9,6 @@ import (
api "github.com/hashicorp/consul/api"
)
var (
// ErrSessionUndefined is exported
ErrSessionUndefined = errors.New("Session does not exist")
)
// Consul embeds the client and watches
type Consul struct {
config *api.Config
@ -35,7 +29,7 @@ type Watch struct {
// InitializeConsul creates a new Consul client given
// a list of endpoints and optional tls config
func InitializeConsul(endpoints []string, options Config) (Store, error) {
func InitializeConsul(endpoints []string, options *Config) (Store, error) {
s := &Consul{}
s.watches = make(map[string]*Watch)

View File

@ -19,7 +19,7 @@ type Etcd struct {
// InitializeEtcd creates a new Etcd client given
// a list of endpoints and optional tls config
func InitializeEtcd(addrs []string, options Config) (Store, error) {
func InitializeEtcd(addrs []string, options *Config) (Store, error) {
s := &Etcd{}
s.watches = make(map[string]chan<- bool)

View File

@ -11,7 +11,7 @@ import (
type WatchCallback func(kviTuple ...KVEntry)
// Initialize creates a new Store object, initializing the client
type Initialize func(addrs []string, options Config) (Store, error)
type Initialize func(addrs []string, options *Config) (Store, error)
// Store represents the backend K/V storage
// Each store should support every call listed
@ -87,7 +87,7 @@ func init() {
}
// CreateStore creates a an instance of store
func CreateStore(store string, addrs []string, options Config) (Store, error) {
func CreateStore(store string, addrs []string, options *Config) (Store, error) {
if init, exists := stores[store]; exists {
log.WithFields(log.Fields{"store": store}).Debug("Initializing store service")

View File

@ -22,7 +22,7 @@ type zookeeperLock struct {
// InitializeZookeeper creates a new Zookeeper client
// given a list of endpoints and optional tls config
func InitializeZookeeper(endpoints []string, options Config) (Store, error) {
func InitializeZookeeper(endpoints []string, options *Config) (Store, error) {
s := &Zookeeper{}
s.watches = make(map[string]<-chan zk.Event)
s.timeout = 5 * time.Second // default timeout