Skip to content

Commit 03adb99

Browse files
committed
website: Document HTTP changes
1 parent 91bed7b commit 03adb99

File tree

1 file changed

+47
-11
lines changed

1 file changed

+47
-11
lines changed

website/source/docs/agent/http.html.markdown

+47-11
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,40 @@ note is that when the query returns there is **no guarantee** of a change. It is
4242
possible that the timeout was reached, or that there was an idempotent write that
4343
does not affect the result.
4444

45+
## Consistency Modes
46+
47+
Most of the read query endpoints support multiple levels of consistency.
48+
These are to provide a tuning knob that clients can be used to find a happy
49+
medium that best matches their needs.
50+
51+
The three read modes are:
52+
53+
* default - If not specified, this mode is used. It is strongly consistent
54+
in almost all cases. However, there is a small window in which an new
55+
leader may be elected, and the old leader may service stale values. The
56+
trade off is fast reads, but potentially stale values. This condition is
57+
hard to trigger, and most clients should not need to worry about the stale read.
58+
This only applies to reads, and a split-brain is not possible on writes.
59+
60+
* consistent - This mode is strongly consistent without caveats. It requires
61+
that a leader verify with a quorum of peers that it is still leader. This
62+
introduces an additional round-trip to all server nodes. The trade off is
63+
always consistent reads, but increased latency due to an extra round trip.
64+
Most clients should not use this unless they cannot tolerate a stale read.
65+
66+
* stale - This mode allows any server to service the read, regardless of if
67+
it is the leader. This means reads can be arbitrarily stale, but are generally
68+
within 50 milliseconds of the leader. The trade off is very fast and scalable
69+
reads but values will be stale. This mode allows reads without a leader, meaning
70+
a cluster that is unavailable will still be able to respond.
71+
72+
To switch these modes, either the "?stale" or "?consistent" query parameters
73+
are provided. It is an error to provide both.
74+
75+
To support bounding how stale data is, there is an "X-Consul-LastContact"
76+
which is the last time a server was contacted by the leader node in
77+
milliseconds. The "X-Consul-KnownLeader" also indicates if there is a known
78+
leader. These can be used to gauage if a stale read should be used.
4579

4680
## KV
4781

@@ -81,7 +115,8 @@ that modified this key. This index corresponds to the `X-Consul-Index`
81115
header value that is returned. A blocking query can be used to wait for
82116
a value to change. If "?recurse" is used, the `X-Consul-Index` corresponds
83117
to the latest `ModifyIndex` and so a blocking query waits until any of the
84-
listed keys are updated.
118+
listed keys are updated. The multiple consistency modes can be used for
119+
`GET` requests as well.
85120

86121
The `Key` is simply the full path of the entry. `Flags` are an opaque
87122
unsigned integer that can be attached to each entry. The use of this is
@@ -347,7 +382,8 @@ The following endpoints are supported:
347382
* /v1/catalog/service/\<service\> : Lists the nodes in a given service
348383
* /v1/catalog/node/\<node\> : Lists the services provided by a node
349384

350-
The last 4 endpoints of the catalog support blocking queries.
385+
The last 4 endpoints of the catalog support blocking queries and
386+
consistency modes.
351387

352388
### /v1/catalog/register
353389

@@ -473,7 +509,7 @@ It returns a JSON body like this:
473509
}
474510
]
475511

476-
This endpoint supports blocking queries.
512+
This endpoint supports blocking queries and all consistency modes.
477513

478514
### /v1/catalog/services
479515

@@ -492,7 +528,7 @@ It returns a JSON body like this:
492528
The main object keys are the service names, while the array
493529
provides all the known tags for a given service.
494530

495-
This endpoint supports blocking queries.
531+
This endpoint supports blocking queries and all consistency modes.
496532

497533
### /v1/catalog/service/\<service\>
498534

@@ -517,7 +553,7 @@ It returns a JSON body like this:
517553
}
518554
]
519555

520-
This endpoint supports blocking queries.
556+
This endpoint supports blocking queries and all consistency modes.
521557

522558
### /v1/catalog/node/\<node\>
523559

@@ -549,7 +585,7 @@ It returns a JSON body like this:
549585
}
550586
}
551587

552-
This endpoint supports blocking queries.
588+
This endpoint supports blocking queries and all consistency modes.
553589

554590
## Health
555591

@@ -564,7 +600,7 @@ The following endpoints are supported:
564600
* /v1/health/service/\<service\>: Returns the nodes and health info of a service
565601
* /v1/health/state/\<state\>: Returns the checks in a given state
566602

567-
All of the health endpoints supports blocking queries.
603+
All of the health endpoints supports blocking queries and all consistency modes.
568604

569605
### /v1/health/node/\<node\>
570606

@@ -603,7 +639,7 @@ joins the Consul cluster, it is part of a distributed failure detection
603639
provided by Serf. If a node fails, it is detected and the status is automatically
604640
changed to "critical".
605641

606-
This endpoint supports blocking queries.
642+
This endpoint supports blocking queries and all consistency modes.
607643

608644
### /v1/health/checks/\<service\>
609645

@@ -627,7 +663,7 @@ It returns a JSON body like this:
627663
}
628664
]
629665

630-
This endpoint supports blocking queries.
666+
This endpoint supports blocking queries and all consistency modes.
631667

632668
### /v1/health/service/\<service\>
633669

@@ -684,7 +720,7 @@ It returns a JSON body like this:
684720
}
685721
]
686722

687-
This endpoint supports blocking queries.
723+
This endpoint supports blocking queries and all consistency modes.
688724

689725
### /v1/health/state/\<state\>
690726

@@ -718,7 +754,7 @@ It returns a JSON body like this:
718754
}
719755
]
720756

721-
This endpoint supports blocking queries.
757+
This endpoint supports blocking queries and all consistency modes.
722758

723759
## Status
724760

0 commit comments

Comments
 (0)