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

..17-May-2021-

LICENSEH A D17-May-202115.6 KiB355256

README.mdH A D17-May-20211.3 KiB6849

acl.goH A D17-May-202138.1 KiB1,4091,048

agent.goH A D17-May-202139 KiB1,206813

api.goH A D17-May-202130.7 KiB1,096692

catalog.goH A D17-May-20218.7 KiB338274

config_entry.goH A D17-May-202115.2 KiB495320

config_entry_cluster.goH A D17-May-2021918 4031

config_entry_discoverychain.goH A D17-May-202110.1 KiB290208

config_entry_gateways.goH A D17-May-20216.1 KiB19177

config_entry_intentions.goH A D17-May-20212.1 KiB8162

connect.goH A D17-May-2021299 137

connect_ca.goH A D17-May-20215.3 KiB190114

connect_intention.goH A D17-May-202112 KiB415263

coordinate.goH A D17-May-20212.6 KiB10780

debug.goH A D17-May-20212.7 KiB10766

discovery_chain.goH A D17-May-20215.7 KiB233146

event.goH A D17-May-20212.6 KiB10581

go.modH A D17-May-2021424 1713

go.sumH A D17-May-202111.2 KiB121120

health.goH A D17-May-202110.4 KiB377299

kv.goH A D17-May-20218 KiB291207

lock.goH A D17-May-202111.1 KiB409269

namespace.goH A D17-May-20214.4 KiB160110

operator.goH A D17-May-2021241 127

operator_area.goH A D17-May-20215.4 KiB195115

operator_autopilot.goH A D17-May-202112 KiB379232

operator_keyring.goH A D17-May-20212.3 KiB9366

operator_license.goH A D17-May-20212.8 KiB11576

operator_raft.goH A D17-May-20212.5 KiB9049

operator_segment.goH A D17-May-2021289 129

prepared_query.goH A D17-May-20217.3 KiB224103

raw.goH A D17-May-2021749 2513

semaphore.goH A D17-May-202114.3 KiB531358

session.goH A D17-May-20215.9 KiB244188

snapshot.goH A D17-May-20211.2 KiB4832

status.goH A D17-May-20211.2 KiB6245

txn.goH A D17-May-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