Esempio n. 1
0
func (cc *Controller) Watch(ctx climax.Context) int {
	printer.Logf("watching namespace: %s", cc.Config.Namespace)

	cc.Client.Watch()

	return 0
}
Esempio n. 2
0
func NewDefault(cfg *config.Config) (stores.IFace, error) {
	apiConfig := api.DefaultConfig()
	if cfg.Consul.Address != "" {
		printer.Logf("Setting consul address to %s in config", cfg.Consul.Address)
		apiConfig.Address = cfg.Consul.Address
	}
	client, err := api.NewClient(apiConfig)

	if err != nil {
		return nil, err
	}

	return &Store{
		cfg: cfg,
		kv:  client.KV(),
		qo:  nil,
		wo:  nil,
	}, nil
}
Esempio n. 3
0
func (cc *Controller) Serve(ctx climax.Context) int {
	c, err := client.New(cc.Config)

	if err != nil {
		printer.LogErrf("%v", err)
	}

	s := server.New(cc.Config, c)

	printer.Logf("pid: %d serving %s on %s", os.Getpid(),
		cc.Config.Server.Endpoint, cc.Config.Server.Host)

	err = s.Serve()

	if err != nil {
		printer.LogErrf("%v", err)
		return 1
	}

	return 0
}
Esempio n. 4
0
File: client.go Progetto: vsco/dcdr
func (c *Client) WriteOutputFile(kvb stores.KVBytes) {
	fts, err := c.KVsToFeatureMap(kvb)

	if err != nil {
		printer.LogErrf("parse features error: %v", err)
		os.Exit(1)
	}

	bts, err := json.MarshalIndent(fts, "", "  ")

	if err != nil {
		printer.LogErrf("%v", err)
		os.Exit(1)
	}

	err = ioutil.WriteFile(c.config.Watcher.OutputPath, bts, 0644)

	if err != nil {
		printer.LogErrf("%v", err)
		os.Exit(1)
	}

	printer.Logf("wrote changes to: %s", c.config.Watcher.OutputPath)
}