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

..15-Oct-2021-

LICENSEH A D15-Oct-202115.6 KiB355256

README.mdH A D15-Oct-20211.3 KiB6849

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

agent.goH A D15-Oct-202139.5 KiB1,212819

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

catalog.goH A D15-Oct-20218.7 KiB338274

config_entry.goH A D15-Oct-202115.5 KiB500321

config_entry_cluster.goH A D15-Oct-20211.1 KiB5441

config_entry_discoverychain.goH A D15-Oct-202110.1 KiB290208

config_entry_gateways.goH A D15-Oct-20216.1 KiB19177

config_entry_intentions.goH A D15-Oct-20212.1 KiB8162

connect.goH A D15-Oct-2021299 137

connect_ca.goH A D15-Oct-20215.3 KiB189113

connect_intention.goH A D15-Oct-202112.1 KiB415263

coordinate.goH A D15-Oct-20212.7 KiB10780

debug.goH A D15-Oct-20213.1 KiB12378

discovery_chain.goH A D15-Oct-20215.7 KiB233146

event.goH A D15-Oct-20212.7 KiB10682

go.modH A D15-Oct-2021424 1713

go.sumH A D15-Oct-202111.2 KiB121120

health.goH A D15-Oct-202110.4 KiB377299

kv.goH A D15-Oct-20218.1 KiB292208

lock.goH A D15-Oct-202111.1 KiB409269

namespace.goH A D15-Oct-20214.4 KiB160110

operator.goH A D15-Oct-2021241 127

operator_area.goH A D15-Oct-20215.4 KiB195115

operator_autopilot.goH A D15-Oct-202112 KiB379232

operator_keyring.goH A D15-Oct-20212.3 KiB9366

operator_license.goH A D15-Oct-20213.1 KiB12076

operator_raft.goH A D15-Oct-20212.5 KiB9049

operator_segment.goH A D15-Oct-2021289 129

prepared_query.goH A D15-Oct-20217.3 KiB224103

raw.goH A D15-Oct-2021749 2513

semaphore.goH A D15-Oct-202114.3 KiB531358

session.goH A D15-Oct-20215.9 KiB244188

snapshot.goH A D15-Oct-20211.3 KiB4933

status.goH A D15-Oct-20211.2 KiB6245

txn.goH A D15-Oct-20216.5 KiB245138

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