1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-06 08:16:03 +02:00
go-micro/cmd/cmd.go

42 lines
947 B
Go
Raw Normal View History

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()
case "memory":
store.DefaultStore = store.NewMemoryStore()
2015-03-06 20:59:24 +02:00
case "etcd":
store.DefaultStore = store.NewEtcdStore()
}
}