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

..30-Jul-2020-

watch/H30-Jul-2020-2,1271,669

.golangci.ymlH A D30-Jul-2020777 3427

README.mdH A D30-Jul-20201.3 KiB6849

acl.goH A D30-Jul-202037 KiB1,3641,013

acl_test.goH A D30-Jul-202017.6 KiB763603

agent.goH A D30-Jul-202033.1 KiB1,052739

agent_test.goH A D30-Jul-202040.6 KiB1,8021,493

api.goH A D30-Jul-202029.4 KiB1,042658

api_test.goH A D30-Jul-202024.7 KiB1,004900

catalog.goH A D30-Jul-20208.7 KiB338274

catalog_test.goH A D30-Jul-202028.5 KiB1,238986

config_entry.goH A D30-Jul-20209.6 KiB354255

config_entry_discoverychain.goH A D30-Jul-20206 KiB204173

config_entry_discoverychain_test.goH A D30-Jul-20206 KiB236194

config_entry_gateways.goH A D30-Jul-20205.7 KiB17163

config_entry_gateways_test.goH A D30-Jul-20207.5 KiB285212

config_entry_test.goH A D30-Jul-202016 KiB758700

connect.goH A D30-Jul-2020299 137

connect_ca.goH A D30-Jul-20204.9 KiB182113

connect_ca_test.goH A D30-Jul-20202.6 KiB10676

connect_intention.goH A D30-Jul-20209 KiB310191

connect_intention_test.goH A D30-Jul-20203.8 KiB190143

coordinate.goH A D30-Jul-20202.6 KiB10780

coordinate_test.goH A D30-Jul-20202.2 KiB10884

debug.goH A D30-Jul-20202.7 KiB10766

debug_test.goH A D30-Jul-20201.4 KiB8465

discovery_chain.goH A D30-Jul-20205.6 KiB230145

discovery_chain_test.goH A D30-Jul-20205.5 KiB196177

event.goH A D30-Jul-20202.6 KiB10581

event_test.goH A D30-Jul-2020802 5139

go.modH A D30-Jul-2020424 1713

go.sumH A D30-Jul-202012.1 KiB132131

health.goH A D30-Jul-202010.3 KiB376298

health_test.goH A D30-Jul-202014.9 KiB672565

kv.goH A D30-Jul-20208 KiB291207

kv_test.goH A D30-Jul-202011.7 KiB581467

lock.goH A D30-Jul-202011 KiB404264

lock_test.goH A D30-Jul-202012 KiB585441

namespace.goH A D30-Jul-20204.3 KiB160110

namespace_test.goH A D30-Jul-20202.8 KiB130102

operator.goH A D30-Jul-2020241 127

operator_area.goH A D30-Jul-20205.4 KiB195115

operator_autopilot.goH A D30-Jul-20206.8 KiB233134

operator_autopilot_test.goH A D30-Jul-20202.3 KiB10891

operator_keyring.goH A D30-Jul-20202.2 KiB9065

operator_keyring_test.goH A D30-Jul-20201.6 KiB7460

operator_license.goH A D30-Jul-20202.8 KiB11576

operator_raft.goH A D30-Jul-20202.5 KiB9049

operator_raft_test.goH A D30-Jul-2020817 3931

operator_segment.goH A D30-Jul-2020289 129

oss_test.goH A D30-Jul-202061 62

prepared_query.goH A D30-Jul-20207.3 KiB224103

prepared_query_test.goH A D30-Jul-20204.2 KiB183149

raw.goH A D30-Jul-2020749 2513

semaphore.goH A D30-Jul-202014.3 KiB531358

semaphore_test.goH A D30-Jul-202011.4 KiB543411

session.goH A D30-Jul-20205.9 KiB244188

session_test.goH A D30-Jul-202012.9 KiB659532

snapshot.goH A D30-Jul-20201.2 KiB4832

snapshot_test.goH A D30-Jul-20203.3 KiB136101

status.goH A D30-Jul-2020932 4433

status_test.goH A D30-Jul-2020587 4032

txn.goH A D30-Jul-20206.5 KiB245138

txn_test.goH A D30-Jul-20207.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