Pure: fault injection through Toxiproxy as an interposed capability (hc-12).
A Need {:via :toxiproxy} puts a proxy between its consumer and the
instance that answers it. One toxiproxy container serves a whole run:
pg:5432 in the consumer's config is right as
written) plus one internal alias, listen-alias, unique per consumer;upstream-alias
(unique per instance, so a shared and a private instance of one
capability never collide);<listen-alias>:<port> (the provider's :port)
and forwards to <upstream-alias>:<port>. Toxiproxy resolves the listen
host through Docker DNS inside its own container when the proxy is
created, to its own address on that view network, so one port serves
different consumers on different view networks. Toxiproxy must
therefore be connected to a view network before its proxies are made.Consumers with a proxy, and every suite consumer suite:<id> of a run
holding one, get TOXIPROXY_URL (the REST API, port 8474, under the
consumer's listen alias) and TOXIPROXY_PROXIES (the proxy names they may
drive, comma-separated; a suite may drive all of them).
Toxiproxy is NOT an instance of the hc-4 StackPlan: interpose-plan
names it in consumers' attach lists only, so the stack ops must bring it
up (project-spec, --wait) and run joins and install! BEFORE any
consumer starts; the hc-6 readiness gate does not see it.
plan answers the interposition; interpose-plan rewrites the hc-4
StackPlan and interpose the hc-5 Wirings with it: a consumer's attach keeps exactly the aliases it had, only the
instance answering them changes. project-spec and joins are what the
stack ops (hc-6, IStackEngine) run; hive-compose.pipeline.faults
creates the proxies through IToxiproxyClient.
Pure: fault injection through Toxiproxy as an interposed capability (hc-12).
A Need `{:via :toxiproxy}` puts a proxy between its consumer and the
instance that answers it. One toxiproxy container serves a whole run:
- it joins the consumer's view network under the ORIGINAL aliases of the
interposed instance (so `pg:5432` in the consumer's config is right as
written) plus one internal alias, `listen-alias`, unique per consumer;
- the real instance leaves that consumer's view network and is reached by
toxiproxy alone, on the run's faults network, under `upstream-alias`
(unique per instance, so a shared and a private instance of one
capability never collide);
- each proxy listens on `<listen-alias>:<port>` (the provider's `:port`)
and forwards to `<upstream-alias>:<port>`. Toxiproxy resolves the listen
host through Docker DNS inside its own container when the proxy is
created, to its own address on that view network, so one port serves
different consumers on different view networks. Toxiproxy must
therefore be connected to a view network before its proxies are made.
Consumers with a proxy, and every suite consumer `suite:<id>` of a run
holding one, get TOXIPROXY_URL (the REST API, port 8474, under the
consumer's listen alias) and TOXIPROXY_PROXIES (the proxy names they may
drive, comma-separated; a suite may drive all of them).
Toxiproxy is NOT an instance of the hc-4 StackPlan: `interpose-plan`
names it in consumers' attach lists only, so the stack ops must bring it
up (`project-spec`, --wait) and run `joins` and `install!` BEFORE any
consumer starts; the hc-6 readiness gate does not see it.
`plan` answers the interposition; `interpose-plan` rewrites the hc-4
StackPlan and `interpose` the hc-5 Wirings with it: a consumer's attach keeps exactly the aliases it had, only the
instance answering them changes. `project-spec` and `joins` are what the
stack ops (hc-6, IStackEngine) run; `hive-compose.pipeline.faults`
creates the proxies through IToxiproxyClient.(active? p)True when plan p interposes anything.
True when plan `p` interposes anything.
Toxiproxy's REST API port inside its container.
Toxiproxy's REST API port inside its container.
(compose-project run)The compose project the run's toxiproxy runs under.
The compose project the run's toxiproxy runs under.
Classpath resource of the compose fragment running toxiproxy.
Classpath resource of the compose fragment running toxiproxy.
(consumer-needs settings extra-needs consumer)The Needs consumer declared: a suite's :suite/needs, a project's or a
section's :project/needs, merged with extra-needs ({consumer Needs},
e.g. a stack's own :stack/needs).
The Needs `consumer` declared: a suite's `:suite/needs`, a project's or a
section's `:project/needs`, merged with `extra-needs` ({consumer Needs},
e.g. a stack's own `:stack/needs`).(faults-network run)The run's faults network, toxiproxy and the interposed instances only: the
view network of the pseudo consumer faults.
The run's faults network, toxiproxy and the interposed instances only: the view network of the pseudo consumer `faults`.
The id the run's toxiproxy takes in attach lists and labels.
The id the run's toxiproxy takes in attach lists and labels.
(interpose p wirings)Result<{consumer Wiring}>: wirings (hc-5) rewritten by plan p. A
consumer the plan does not name is returned unchanged; for one it names,
the set of aliases on its attach list is unchanged, only the instance
answering the interposed ones becomes toxiproxy (with :internal-aliases
[listen-alias] beside them, for the stack ops to connect too). A suite
with no proxy of its own keeps its attach list and gets the env alone;
joins connects toxiproxy to its view network under its listen alias, so
it reaches the API. Each Wiring still conforms to schema/Wiring.
Result<{consumer Wiring}>: `wirings` (hc-5) rewritten by plan `p`. A
consumer the plan does not name is returned unchanged; for one it names,
the set of aliases on its attach list is unchanged, only the instance
answering the interposed ones becomes toxiproxy (with `:internal-aliases`
[listen-alias] beside them, for the stack ops to connect too). A suite
with no proxy of its own keeps its attach list and gets the env alone;
`joins` connects toxiproxy to its view network under its listen alias, so
it reaches the API. Each Wiring still conforms to schema/Wiring.(interpose-plan p sp)StackPlan sp (hive-compose.promote.stack/stack-plan, as the hc-6 stack
ops consume it) rewritten by faults plan p, so that what the ops connect
matches the interposition:
:instance/networks), so Docker DNS answers the
original alias on that network with toxiproxy alone;:consumer/attach names toxiproxy, not the
instance, for the interposed aliases (aliases unchanged);:stack/networks gains the faults network, so the ops create it
(labelled like every stack network) before anything joins it.
The instance reaches the faults network, and toxiproxy every view network,
through joins. sp is returned as it is when p interposes nothing.StackPlan `sp` (hive-compose.promote.stack/stack-plan, as the hc-6 stack ops consume it) rewritten by faults plan `p`, so that what the ops connect matches the interposition: - each interposed instance leaves the view network of every consumer it is interposed for (`:instance/networks`), so Docker DNS answers the original alias on that network with toxiproxy alone; - each such consumer's `:consumer/attach` names toxiproxy, not the instance, for the interposed aliases (aliases unchanged); - `:stack/networks` gains the faults network, so the ops create it (labelled like every stack network) before anything joins it. The instance reaches the faults network, and toxiproxy every view network, through `joins`. `sp` is returned as it is when `p` interposes nothing.
(joins p)[{:network :instance :aliases}]: the -network-connect! calls plan p
needs, toxiproxy's first (it joins the faults network through its spec).
Toxiproxy joins each consumer's view network under the interposed
aliases and its listen alias; each interposed instance joins the faults
network under its upstream alias. The stack ops map an instance id to
its {:project :service} target.
[{:network :instance :aliases}]: the `-network-connect!` calls plan `p`
needs, toxiproxy's first (it joins the faults network through its spec).
Toxiproxy joins each consumer's view network under the interposed
aliases and its listen alias; each interposed instance joins the faults
network under its upstream alias. The stack ops map an instance id to
its {:project :service} target.(listen-alias consumer)Toxiproxy's internal alias on consumer's view network: the host its
proxies for that consumer listen on, and the TOXIPROXY_URL host.
Toxiproxy's internal alias on `consumer`'s view network: the host its proxies for that consumer listen on, and the TOXIPROXY_URL host.
(plan settings resolution run)(plan settings resolution run extra-needs)Result<Plan> of the interposition in run run over resolution.
extra-needs ({consumer Needs}) adds needs settings do not hold (a
stack's :stack/needs). With no Need :via :toxiproxy the plan holds no
proxy and :faults/toxiproxy is nil. Otherwise:
{:faults/run :faults/network :faults/toxiproxy {:id :image :service :compose-project :api-port :labels} :faults/proxies [{:proxy/name :proxy/consumer :proxy/capability :proxy/instance :proxy/aliases :proxy/port :proxy/listen :proxy/upstream}] :faults/consumers {consumer {:aliases :instances :listen-alias}} :faults/env {consumer {TOXIPROXY_URL .. TOXIPROXY_PROXIES ..}}}
Errors: :compose/invalid-run, :compose/unknown-via, :compose/unknown-instance, :compose/faults-missing-port, :compose/faults-port-clash, :compose/faults-alias-clash.
Result<Plan> of the interposition in run `run` over `resolution`.
`extra-needs` ({consumer Needs}) adds needs settings do not hold (a
stack's `:stack/needs`). With no Need `:via :toxiproxy` the plan holds no
proxy and `:faults/toxiproxy` is nil. Otherwise:
{:faults/run :faults/network
:faults/toxiproxy {:id :image :service :compose-project :api-port :labels}
:faults/proxies [{:proxy/name :proxy/consumer :proxy/capability
:proxy/instance :proxy/aliases :proxy/port
:proxy/listen :proxy/upstream}]
:faults/consumers {consumer {:aliases :instances :listen-alias}}
:faults/env {consumer {TOXIPROXY_URL .. TOXIPROXY_PROXIES ..}}}
Errors: :compose/invalid-run, :compose/unknown-via,
:compose/unknown-instance, :compose/faults-missing-port,
:compose/faults-port-clash, :compose/faults-alias-clash.(project-spec p dir)The IStackEngine ProjectSpec bringing the run's toxiproxy up from the
compose fragment written into dir (compose-resource), on the faults
network, labelled, with --wait.
The IStackEngine ProjectSpec bringing the run's toxiproxy up from the compose fragment written into `dir` (`compose-resource`), on the faults network, labelled, with `--wait`.
(proxy-config pr)The toxiproxy REST body creating proxy pr.
The toxiproxy REST body creating proxy `pr`.
(proxy-name consumer cap)The toxiproxy proxy name of consumer's capability cap.
The toxiproxy proxy name of `consumer`'s capability `cap`.
The compose service of the bundled fragment.
The compose service of the bundled fragment.
(teardown p dir)[step]: what stack-down of the run must undo for plan p, in order, as
IStackEngine calls. 1. -down-project! of toxiproxy's compose project
with :all? (removing its container disconnects it from every view
network). 2. -network-rm! of the faults network (which disconnects the
interposed instances still attached, shared ones included). [] when p
interposes nothing.
[step]: what stack-down of the run must undo for plan `p`, in order, as IStackEngine calls. 1. `-down-project!` of toxiproxy's compose project with :all? (removing its container disconnects it from every view network). 2. `-network-rm!` of the faults network (which disconnects the interposed instances still attached, shared ones included). [] when `p` interposes nothing.
(toxic spec)Result<toxic body> of a toxic spec as the faults command takes it:
{:type :attributes {name number} :stream upstream|downstream
:toxicity 0..1 :name}. The name defaults to <type>_<stream>.
Result<toxic body> of a toxic spec as the `faults` command takes it:
{:type :attributes {name number} :stream upstream|downstream
:toxicity 0..1 :name}. The name defaults to `<type>_<stream>`.(toxic-name spec)The name of the toxic a remove names: its :name, else <type>_<stream>
(stream downstream by default), nil when neither is usable.
The name of the toxic a remove names: its :name, else `<type>_<stream>` (stream downstream by default), nil when neither is usable.
Toxic types toxiproxy 2.x implements, with the attributes each reads.
Toxic types toxiproxy 2.x implements, with the attributes each reads.
The ghcr.io/shopify/toxiproxy tag the compose fragment pins.
The ghcr.io/shopify/toxiproxy tag the compose fragment pins.
(upstream-alias id)The alias instance id joins the faults network under.
The alias instance `id` joins the faults network under.
The :via value that interposes toxiproxy.
The `:via` value that interposes toxiproxy.
(word x)A keyword, symbol or string as its name; anything else (a number, a map, nil) as nil. Total: never throws on what JSON can send.
A keyword, symbol or string as its name; anything else (a number, a map, nil) as nil. Total: never throws on what JSON can send.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |