• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..28-Jan-2019-

README.mdH A D28-Jan-20191.3 KiB6849

acl.goH A D28-Jan-201915.1 KiB589441

acl_test.goH A D28-Jan-201916.7 KiB727575

agent.goH A D28-Jan-201929.1 KiB967684

agent_test.goH A D28-Jan-201933.5 KiB1,4921,242

api.goH A D28-Jan-201924.9 KiB900572

api_test.goH A D28-Jan-201915.5 KiB645549

catalog.goH A D28-Jan-20196 KiB245200

catalog_test.goH A D28-Jan-201920.9 KiB931742

connect.goH A D28-Jan-2019299 137

connect_ca.goH A D28-Jan-20194.5 KiB175111

connect_ca_test.goH A D28-Jan-20192.3 KiB9670

connect_intention.goH A D28-Jan-20198.7 KiB303190

connect_intention_test.goH A D28-Jan-20193.8 KiB188141

coordinate.goH A D28-Jan-20192.6 KiB10780

coordinate_test.goH A D28-Jan-20192.2 KiB10783

debug.goH A D28-Jan-20192.7 KiB10766

debug_test.goH A D28-Jan-20191.4 KiB8465

event.goH A D28-Jan-20192.6 KiB10581

event_test.goH A D28-Jan-2019798 5139

health.goH A D28-Jan-20199 KiB331261

health_test.goH A D28-Jan-20199.9 KiB482432

kv.goH A D28-Jan-20197.8 KiB287206

kv_test.goH A D28-Jan-201911.6 KiB575463

lock.goH A D28-Jan-201910.5 KiB387252

lock_test.goH A D28-Jan-201911.9 KiB583439

operator.goH A D28-Jan-2019241 127

operator_area.goH A D28-Jan-20195.4 KiB195115

operator_autopilot.goH A D28-Jan-20196.5 KiB220127

operator_autopilot_test.goH A D28-Jan-20192.3 KiB10891

operator_keyring.goH A D28-Jan-20192.2 KiB9065

operator_keyring_test.goH A D28-Jan-20191.6 KiB7460

operator_raft.goH A D28-Jan-20192.5 KiB9049

operator_raft_test.goH A D28-Jan-2019817 3931

operator_segment.goH A D28-Jan-2019289 129

prepared_query.goH A D28-Jan-20196.9 KiB213100

prepared_query_test.goH A D28-Jan-20194.1 KiB181147

raw.goH A D28-Jan-2019749 2513

semaphore.goH A D28-Jan-201913.8 KiB515347

semaphore_test.goH A D28-Jan-201911.2 KiB532405

session.goH A D28-Jan-20195.4 KiB225175

session_test.goH A D28-Jan-20197.9 KiB436337

snapshot.goH A D28-Jan-20191.2 KiB4832

snapshot_test.goH A D28-Jan-20193.3 KiB135100

status.goH A D28-Jan-2019932 4433

status_test.goH A D28-Jan-2019587 4032

txn.goH A D28-Jan-20196.2 KiB231129

txn_test.goH A D28-Jan-20197 KiB291267

README.md

1Consul API client
2=================
3
4This package provides the `api` package which attempts to
5provide programmatic access to the full Consul API.
6
7Currently, all of the Consul APIs included in version 0.6.0 are supported.
8
9Documentation
10=============
11
12The full documentation is available on [Godoc](https://godoc.org/github.com/hashicorp/consul/api)
13
14Usage
15=====
16
17Below is an example of using the Consul client:
18
19```go
20package main
21
22import "github.com/hashicorp/consul/api"
23import "fmt"
24
25func main() {
26	// Get a new client
27	client, err := api.NewClient(api.DefaultConfig())
28	if err != nil {
29		panic(err)
30	}
31
32	// Get a handle to the KV API
33	kv := client.KV()
34
35	// PUT a new KV pair
36	p := &api.KVPair{Key: "REDIS_MAXCLIENTS", Value: []byte("1000")}
37	_, err = kv.Put(p, nil)
38	if err != nil {
39		panic(err)
40	}
41
42	// Lookup the pair
43	pair, _, err := kv.Get("REDIS_MAXCLIENTS", nil)
44	if err != nil {
45		panic(err)
46	}
47	fmt.Printf("KV: %v %s\n", pair.Key, pair.Value)
48}
49```
50
51To run this example, start a Consul server:
52
53```bash
54consul agent -dev
55```
56
57Copy the code above into a file such as `main.go`.
58
59Install and run. You'll see a key (`REDIS_MAXCLIENTS`) and value (`1000`) printed.
60
61```bash
62$ go get
63$ go run main.go
64KV: REDIS_MAXCLIENTS 1000
65```
66
67After running the code, you can also view the values in the Consul UI on your local machine at http://localhost:8500/ui/dc1/kv
68