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

..15-Jul-2021-

watch/H15-Jul-2021-2,1331,674

.golangci.ymlH A D15-Jul-20212 KiB6351

README.mdH A D15-Jul-20211.3 KiB6849

acl.goH A D15-Jul-202138.4 KiB1,4111,050

acl_test.goH A D15-Jul-202121 KiB862690

agent.goH A D15-Jul-202139.4 KiB1,211818

agent_test.goH A D15-Jul-202144.1 KiB1,9691,636

api.goH A D15-Jul-202131.3 KiB1,110699

api_test.goH A D15-Jul-202126.5 KiB1,081961

catalog.goH A D15-Jul-20218.7 KiB338274

catalog_test.goH A D15-Jul-202128.6 KiB1,242990

config_entry.goH A D15-Jul-202115.5 KiB500321

config_entry_cluster.goH A D15-Jul-20211.1 KiB5441

config_entry_discoverychain.goH A D15-Jul-202110.1 KiB290208

config_entry_discoverychain_test.goH A D15-Jul-20219.4 KiB375313

config_entry_gateways.goH A D15-Jul-20216.1 KiB19177

config_entry_gateways_test.goH A D15-Jul-20217.8 KiB297224

config_entry_intentions.goH A D15-Jul-20212.1 KiB8162

config_entry_intentions_test.goH A D15-Jul-20213.2 KiB137104

config_entry_test.goH A D15-Jul-202126.1 KiB1,2631,192

connect.goH A D15-Jul-2021299 137

connect_ca.goH A D15-Jul-20215.3 KiB189113

connect_ca_test.goH A D15-Jul-20212.5 KiB10473

connect_intention.goH A D15-Jul-202112.1 KiB415263

connect_intention_test.goH A D15-Jul-20213.9 KiB194143

coordinate.goH A D15-Jul-20212.7 KiB10780

coordinate_test.goH A D15-Jul-20212.2 KiB10884

debug.goH A D15-Jul-20213.1 KiB12378

debug_test.goH A D15-Jul-20211.4 KiB8465

discovery_chain.goH A D15-Jul-20215.7 KiB233146

discovery_chain_test.goH A D15-Jul-20215.4 KiB196177

event.goH A D15-Jul-20212.7 KiB10682

event_test.goH A D15-Jul-2021802 5139

go.modH A D15-Jul-2021424 1713

go.sumH A D15-Jul-202111.2 KiB121120

health.goH A D15-Jul-202110.4 KiB377299

health_test.goH A D15-Jul-202114.9 KiB672565

kv.goH A D15-Jul-20218.1 KiB292208

kv_test.goH A D15-Jul-202111.7 KiB581466

lock.goH A D15-Jul-202111.1 KiB409269

lock_test.goH A D15-Jul-202112 KiB587443

mock_api_test.goH A D15-Jul-20211.6 KiB8366

namespace.goH A D15-Jul-20214.4 KiB160110

namespace_test.goH A D15-Jul-20212.7 KiB130102

operator.goH A D15-Jul-2021241 127

operator_area.goH A D15-Jul-20215.4 KiB195115

operator_autopilot.goH A D15-Jul-202112 KiB379232

operator_autopilot_test.goH A D15-Jul-20214.3 KiB185162

operator_keyring.goH A D15-Jul-20212.3 KiB9366

operator_keyring_test.goH A D15-Jul-20211.6 KiB7460

operator_license.goH A D15-Jul-20212.7 KiB9553

operator_raft.goH A D15-Jul-20212.5 KiB9049

operator_raft_test.goH A D15-Jul-2021817 3931

operator_segment.goH A D15-Jul-2021289 129

oss_test.goH A D15-Jul-202161 62

prepared_query.goH A D15-Jul-20217.3 KiB224103

prepared_query_test.goH A D15-Jul-20214.2 KiB183149

raw.goH A D15-Jul-2021749 2513

semaphore.goH A D15-Jul-202114.3 KiB531358

semaphore_test.goH A D15-Jul-202111.4 KiB545413

session.goH A D15-Jul-20215.9 KiB244188

session_test.goH A D15-Jul-202112.9 KiB660532

snapshot.goH A D15-Jul-20211.3 KiB4933

snapshot_test.goH A D15-Jul-20213.3 KiB136101

status.goH A D15-Jul-20211.2 KiB6245

status_test.goH A D15-Jul-20212.1 KiB12095

txn.goH A D15-Jul-20216.5 KiB245138

txn_test.goH A D15-Jul-20217.4 KiB305279

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