Copyedit and formatting changes
@@ -4,7 +4,7 @@ title: Running packages with runtime binding
# Runtime Binding
-*Runtime binding* in Habitat refers to the ability for one service group to connect to another forming a producer/consumer relationship where the consumer can use the producer's publicly available configuration to configure it's services at runtime. We form a [polymorphic relationship](https://en.wikipedia.org/wiki/Polymorphism_(computer_science)) between these two service groups defined by a [dynamically typed](https://en.wikipedia.org/wiki/Duck_typing) contract where the consumer specifies a generic name of the service it is consuming along with the configuration keys it expects the producer to export.
+*Runtime binding* in Habitat refers to the ability for one service group to connect to another forming a producer/consumer relationship where the consumer can use the producer's publicly available configuration to configure it's services at runtime. We form a [polymorphic relationship](https://en.wikipedia.org/wiki/Polymorphism_(computer_science)) between these two service groups defined by a [dynamically-typed](https://en.wikipedia.org/wiki/Duck_typing) contract where the consumer specifies a generic name of the service it is consuming along with the configuration keys it expects the producer to export.
For example, you might have a web application `app-server` that depends on the value of the leader of a database service group. Rather than hardcoding the name of the service group or package identifier in `app-servers`'s plan, which would limit its portability, you can _bind_ the name `database`, for example, to the `default` service group running PostgreSQL. If you have multiple service groups for PostgreSQL - perhaps you have a production and development environment - you could bind `database` to `postgresql.production` or `postgresql.development`. If `app-server` supports multiple different database backends you could even bind `database` to another, such as `redis.default` or `mysql.default`.
@@ -21,7 +21,7 @@ This will export the value of `network.port` and `transport.ssl.port` defined in
## Consumer Contract
-Consumers defines their half of the contract by defining required and optional "binds". These are also represented by key/value pairs in an associative array called `pkg_binds` and `pkg_binds_optional`. For example, An application server named `session-server` that depends on a database might define the following binds:
+Consumers defines their half of the contract by specifying required and optional "binds". These are also represented by key/value pairs in an associative array called `pkg_binds` and `pkg_binds_optional` where the values are the exported keys defined by the producer. For example, an application server named `session-server` that depends on a database might define the following binds:
pkg_binds=(
[database]="port ssl-port"
@@ -45,13 +45,13 @@ Once you've defined both ends of the contract you can leverage the bind in any o
## Starting A Consumer
-Since your application server defined `database` as a required bind, you'll need to provide the name of a service group running a package which fulfills the contract using the `--bind` parameter to the supervisor, for example:
+Since your application server defined `database` as a required bind, you'll need to provide the name of a service group running a package which fulfills the contract using the `--bind` parameter to the supervisor. For example, running the following:
hab start my-origin/app-server --bind database:amnesia.default
-which would create a bind aliasing `database` to the `amnesia` service in the `default` service group.
+would create a bind aliasing `database` to the `amnesia` service in the `default` service group.
-The service group passed to `--bind database:{service}.{group}` doesn't *need* to be the service `amnesia`. Again, this bind can be any service as long as they export a configuration key for `port` and `ssl-port`.
+The service group passed to `--bind database:{service}.{group}` doesn't *need* to be the service `amnesia`. This bind can be any service as long as they export a configuration key for `port` and `ssl-port`.
You can declare bindings to multiple service groups in your templates. The arguments to `--bind` are separated by commas. Your service will not start if your package has declared a required bind and a value for it was not specified by `--bind`.
