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

..19-Feb-2022-

watch/H19-Feb-2022-871654

LICENSEH A D19-Feb-202215.6 KiB355256

README.mdH A D19-Feb-20221.3 KiB6849

acl.goH A D19-Feb-202242.4 KiB1,5631,197

agent.goH A D19-Feb-202244.3 KiB1,377960

api.goH A D19-Feb-202233.2 KiB1,175735

catalog.goH A D19-Feb-20229.5 KiB371306

config_entry.goH A D19-Feb-202217.3 KiB513333

config_entry_discoverychain.goH A D19-Feb-202211.9 KiB322226

config_entry_exports.goH A D19-Feb-20222.6 KiB7336

config_entry_gateways.goH A D19-Feb-20227.7 KiB19670

config_entry_intentions.goH A D19-Feb-20222.3 KiB6753

config_entry_mesh.goH A D19-Feb-20221.9 KiB5731

connect.goH A D19-Feb-2022299 137

connect_ca.goH A D19-Feb-20225.5 KiB199123

connect_intention.goH A D19-Feb-202213 KiB450295

coordinate.goH A D19-Feb-20222.9 KiB12093

debug.goH A D19-Feb-20223.6 KiB14093

discovery_chain.goH A D19-Feb-20225.7 KiB235149

event.goH A D19-Feb-20222.8 KiB11288

go.modH A D19-Feb-2022424 1713

go.sumH A D19-Feb-202211.5 KiB125124

health.goH A D19-Feb-202210.6 KiB390312

kv.goH A D19-Feb-20228.3 KiB305216

lock.goH A D19-Feb-202211.1 KiB409269

namespace.goH A D19-Feb-20224.8 KiB179127

operator.goH A D19-Feb-2022241 127

operator_area.goH A D19-Feb-20225.6 KiB207127

operator_autopilot.goH A D19-Feb-202212.5 KiB402256

operator_keyring.goH A D19-Feb-20222.6 KiB10879

operator_license.goH A D19-Feb-20223.3 KiB12985

operator_raft.goH A D19-Feb-20222.7 KiB9758

operator_segment.goH A D19-Feb-2022289 129

partition.goH A D19-Feb-20224 KiB165127

prepared_query.goH A D19-Feb-20227.4 KiB230109

raw.goH A D19-Feb-2022749 2513

semaphore.goH A D19-Feb-202214.3 KiB531358

session.goH A D19-Feb-20225.9 KiB244188

snapshot.goH A D19-Feb-20221.4 KiB5539

status.goH A D19-Feb-20221.3 KiB6851

txn.goH A D19-Feb-20226.5 KiB246139

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