Skip to content

Commit 1c172e7

Browse files
jmacdotorgdormando
authored andcommitted
Move the explanation of set definition to later in the document, replacing its old location with a cross-reference. The new section goes into much more clarity about how sets just give you an alternate way of passing lists of pools to route handlers, with more fleshed-out examples.
1 parent 7ea230c commit 1c172e7

File tree

1 file changed

+66
-43
lines changed

1 file changed

+66
-43
lines changed

content/features/proxy/configure.md

Lines changed: 66 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -120,49 +120,7 @@ pools {
120120
}
121121
```
122122

123-
#### Define sets of pools {#sets}
124-
125-
You can optionally gather pools into named _sets_, each of which contains a list of pool definitions. You might want to employ this technique if you have several pools of backends that you want the router to treat as mutually equivalent with synchronized data:
126-
127-
```lua
128-
{{<var>}}SET_NAME{{</var>}} = {
129-
{
130-
{ backends = {{<var>}}[ ... ]{{</var>}} },
131-
{ backends = {{<var>}}[ ... ]{{</var>}} },
132-
{{<var>}}[ ... ]{{</var>}}
133-
},
134-
{{<var>}}[ ... ]{{</var>}}
135-
}
136-
```
137-
138-
Replace <var>SET_NAME</var> with a name for this set of pools—for example, `set_customer_pools`. The name must begin with `set_`.
139-
140-
{{< callout type="warning" >}}If you don't start a set's name with `set_`, then Memcached reads it as an ordinary pool definition, likely resulting in a syntax error.{{</callout>}}
141-
142-
The following example defines one set named `set_main_pool` which contains the two pools from the previous `pools{}` example:
143-
144-
```lua
145-
pools {
146-
set_main_pools = {
147-
{
148-
backends = {
149-
"192.0.2.1",
150-
"192.0.2.2",
151-
"192.0.2.3:11212",
152-
},
153-
},
154-
{
155-
backends = {
156-
"203.0.113.1",
157-
"203.0.113.10",
158-
{ host = "203.0.113.20", port = 11212, connecttimeout = 10 },
159-
},
160-
},
161-
},
162-
}
163-
```
164-
165-
Sets are also useful when organizing pools into named zones as part of an ordered failover strategy. For more information, see [Prioritize a route using local zones](#zones).
123+
You can optionally define named sets of pools within the `pools{}` block, as well as individual, named pools. For more information, see [Gather related pools into sets](#sets).
166124

167125
### Define proxy routes
168126

@@ -378,6 +336,71 @@ If you have defined the backend using the alternate list-based syntax, then add
378336

379337
To mark the backend as online again, remove the `_down_` or `down=true` attribute from the backend's definition in the proxy configuration file.
380338

339+
## Gather related pools into sets {#sets}
340+
341+
Any route handler that requires a list of pools among its arguments lets you alternately specify a _set_ of pools, instead. You define sets in the `pools{}` section of your configuration file using the following syntax:
342+
343+
```lua
344+
{{<var>}}SET_NAME{{</var>}} = {
345+
{
346+
{ {{<var>}}POOL_DEFINITION{{</var>}} },
347+
{{<var>}}[ ... ]{{</var>}}
348+
},
349+
}
350+
```
351+
352+
Replace the following:
353+
354+
* <var>SET_NAME</var>: the name for this set of pools—for example, `set_customer_pools`. The name must begin with `set_`.
355+
356+
{{< callout type="warning" >}}If you don't start a set's name with `set_`, then Memcached reads it as an ordinary pool definition, likely resulting in a syntax error.{{</callout>}}
357+
358+
* <var>POOL_DEFINITION</var>: a complete, "anonymous" [pool definition](#pools)—that is, it has no pool name attached.
359+
360+
In the simplest case, the definition is `backends = { {{<var>}}[ ... ]{{</var>}} }`, defining a list of the pool's backends.
361+
362+
The following example defines one set named `set_main_pools`, which contains three backends. The example then uses that set to create a [failover route]({{<proxy_base_path>}}reference#route_failover):
363+
364+
```lua
365+
pools {
366+
set_main_pools = {
367+
{
368+
backends = {
369+
"192.0.2.1",
370+
"192.0.2.2",
371+
"192.0.2.3:11212",
372+
},
373+
},
374+
{
375+
backends = {
376+
"203.0.113.1",
377+
"203.0.113.10",
378+
{ host = "203.0.113.20", port = 11212, connecttimeout = 10 },
379+
},
380+
},
381+
},
382+
}
383+
384+
routes {
385+
route_failover {
386+
children = "set_main_pools",
387+
shuffle = true,
388+
},
389+
}
390+
```
391+
392+
When passing arguments to route handlers, the following actions are functionally equivalent:
393+
394+
* Passing a list of pool names to a route handler—for example:
395+
396+
`route_allsync{ children = { "main_pool_1", "main_pool_2" } }`
397+
398+
* Passing a single set name to a route handler—for example:
399+
400+
`route_allsync{ children = "set_main_pools" }`
401+
402+
Choose the technique that makes the most sense for your use case, in terms of the legibility and maintainability of your configuration file.
403+
381404
## Prioritize a route using local zones {#zones}
382405

383406
If you have [organized your pools into named sets](#sets), then you can further configure the proxy to prefer routing requests to certain pools within a set, even if other pools are available. You might want to do this to prefer routing requests to a pool that is geographically closer to the proxy, for example.

0 commit comments

Comments
 (0)