2015-02-15 01:33:21 +02:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
|
|
|
|
"github.com/asim/go-micro/registry"
|
|
|
|
"github.com/asim/go-micro/server"
|
|
|
|
"github.com/asim/go-micro/store"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
flagBindAddress string
|
|
|
|
flagRegistry string
|
|
|
|
flagStore string
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
flag.StringVar(&flagBindAddress, "bind_address", ":0", "Bind address for the server. 127.0.0.1:8080")
|
|
|
|
flag.StringVar(&flagRegistry, "registry", "consul", "Registry for discovery. kubernetes, consul, etc")
|
|
|
|
flag.StringVar(&flagStore, "store", "consul", "Store used as a basic key/value store using consul, memcached, etc")
|
|
|
|
}
|
|
|
|
|
|
|
|
func Init() {
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
server.Address = flagBindAddress
|
|
|
|
|
|
|
|
switch flagRegistry {
|
|
|
|
case "kubernetes":
|
|
|
|
registry.DefaultRegistry = registry.NewKubernetesRegistry()
|
|
|
|
}
|
|
|
|
|
|
|
|
switch flagStore {
|
|
|
|
case "memcached":
|
|
|
|
store.DefaultStore = store.NewMemcacheStore()
|
2015-03-06 21:08:55 +02:00
|
|
|
case "memory":
|
|
|
|
store.DefaultStore = store.NewMemoryStore()
|
2015-03-06 20:59:24 +02:00
|
|
|
case "etcd":
|
|
|
|
store.DefaultStore = store.NewEtcdStore()
|
2015-02-15 01:33:21 +02:00
|
|
|
}
|
|
|
|
}
|