Example #1
0
func setKey(value db.Entity) {
	path, err := value.Path()
	if err != nil {
		panic(err)
	}

	content, err := jsonio.Write(value)
	if err != nil {
		panic(err)
	}

	switch Driver {
	case "etcd":
		client, err := getEtcdClient()
		if err != nil {
			panic(err)
		}

		if _, err := client.Set(context.Background(), fmt.Sprintf("/volplugin/%v", path), string(content), nil); err != nil {
			panic(err)
		}
	case "consul":
		client, err := getConsulClient()
		if err != nil {
			panic(err)
		}

		if _, err := client.KV().Put(&api.KVPair{Key: fmt.Sprintf("volplugin/%v", path), Value: content}, nil); err != nil {
			panic(err)
		}
	}
}
Example #2
0
func setKey(value db.Entity) {
	client, err := getEtcdClient()
	if err != nil {
		panic(err)
	}

	path, err := value.Path()
	if err != nil {
		panic(err)
	}

	content, err := jsonio.Write(value)
	if err != nil {
		panic(err)
	}

	if _, err := client.Set(context.Background(), fmt.Sprintf("/volplugin/%v", path), string(content), nil); err != nil {
		panic(err)
	}
}