Ryan Uber 8455077e5d api: add harnessing for tests
This is necessary as consul-api's tests require a real consul instance
to be running. We can't directly import an agent to fire up an instance,
due to the way this would create an import cycle. These tests instead
will start a consul instance using the binary in $PATH (if it exists).
2015-01-06 15:52:06 -08:00
..
2015-01-06 15:52:06 -08:00
2015-01-06 15:52:06 -08:00
2015-01-06 15:52:06 -08:00
2015-01-06 15:52:06 -08:00
2015-01-06 15:52:06 -08:00
2015-01-06 15:52:06 -08:00
2015-01-06 15:52:06 -08:00
2015-01-06 15:52:06 -08:00
2015-01-06 15:52:06 -08:00

Consul API client

This package provides the api package which attempts to provide programmatic access to the full Consul API.

Currently, all of the Consul APIs included in version 0.3 are supported.

Documentation

The full documentation is available on Godoc

Usage

Below is an example of using the Consul client:

// Get a new client, with KV endpoints
client, _ := api.NewClient(api.DefaultConfig())
kv := client.KV()

// PUT a new KV pair
p := &api.KVPair{Key: "foo", Value: []byte("test")}
_, err := kv.Put(p, nil)
if err != nil {
    panic(err)
}

// Lookup the pair
pair, _, err := kv.Get("foo", nil)
if err != nil {
    panic(err)
}
fmt.Printf("KV: %v", pair)