You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit aaaa921
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: lib/elixir/pages/mix-and-otp/docs-tests-and-with.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -181,7 +181,7 @@ defmodule KV.Command do
181
181
end
182
182
```
183
183
184
-
Before we implement this function, let's change our server to start using our new `parse/1` and `run/1` functions. Remember, our `read_line/1` function was also crashing when the client closed the socket, so let's take the opportunity to fix it, too. Open up `lib/kv/server.ex` and replace the existing server definition:
184
+
Before we implement this function, let's change our server to start using our new `parse/1` and `run/2` functions. Remember, our `read_line/1` function was also crashing when the client closed the socket, so let's take the opportunity to fix it, too. Open up `lib/kv/server.ex` and replace the existing server definition:
185
185
186
186
```elixir
187
187
defpserve(socket) do
@@ -289,7 +289,7 @@ You can read more about `with/1` in our documentation.
289
289
290
290
## Running commands
291
291
292
-
The last step is to implement `KV.Command.run/1` to run the parsed commands on top of buckets. Its implementation is shown below:
292
+
The last step is to implement `KV.Command.run/2` to run the parsed commands on top of buckets. Its implementation is shown below:
293
293
294
294
```elixir
295
295
@doc """
@@ -354,7 +354,7 @@ Our server functionality is almost complete. Only tests are missing.
354
354
355
355
## Integration tests
356
356
357
-
`KV.Command.run/1`'s implementation is sending commands directly to the `KV` module, which is using a local registry to name processes. This means if we have two tests sending messages to the same bucket, our tests will conflict with each other (and likely fail). One might think this would be a reason to use mocks and other strategies to keep our tests isolated, but such techniques often make our testing environment too distant from how our code actually runs in production, and you may end-up with bugs lurking.
357
+
`KV.Command.run/2`'s implementation is sending commands directly to the `KV` module, which is using a local registry to name processes. This means if we have two tests sending messages to the same bucket, our tests will conflict with each other (and likely fail). One might think this would be a reason to use mocks and other strategies to keep our tests isolated, but such techniques often make our testing environment too distant from how our code actually runs in production, and you may end-up with bugs lurking.
358
358
359
359
Luckily, there is a technique that we have been using throughout this guide that would be equally applicable here: it is ok to rely on the local registry as long as each test uses unique names. Using a combination of the test module and test name is more than enough to guarantee that.
@@ -223,7 +223,7 @@ Not only that, as you create new buckets on the terminal, you should see new pro
223
223
224
224
```elixir
225
225
iex>KV.create_bucket("shopping")
226
-
#PID<0.89.0>
226
+
{:ok, #PID<0.89.0>}
227
227
```
228
228
229
229
We will leave it up to you to further explore what Observer provides. Note you can double-click any process in the supervision tree to retrieve more information about it, as well as right-click a process to send "a kill signal", a perfect way to emulate failures and see if your supervisor reacts as expected.
Copy file name to clipboardExpand all lines: lib/elixir/pages/mix-and-otp/genservers.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -300,7 +300,7 @@ Open up `test/kv/server_test.exs` and add this new test:
300
300
301
301
The test creates a bucket and subscribes to it. Then it opens up another TCP connection to send commands. For each command sent, we expect the subscribed socket to receive a message.
302
302
303
-
To make the test pass, we need to change `KV.Command` to parse the new `SUBSCRIBE` command and then run it. Open up `lib/kv/commands.ex` and then first change the `parse/1` definition to the following:
303
+
To make the test pass, we need to change `KV.Command` to parse the new `SUBSCRIBE` command and then run it. Open up `lib/kv/command.ex` and then first change the `parse/1` definition to the following:
Copy file name to clipboardExpand all lines: lib/elixir/pages/mix-and-otp/task-and-gen-tcp.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -221,7 +221,7 @@ Let's change `start/2` in `lib/kv.ex` once more, to add the task supervisor to o
221
221
end
222
222
```
223
223
224
-
We'll now start a `Task.Supervisor` process with name `KV.TaskSupervisor`. Keep in mind that the order children are started matters. For example, the acceptor must come last because, if it comes first, it means our application can start accepting requests before the `Task.Supervisor` is running or before we can locate buckets. Shutting down an application will also stop the children in reverse order, guaranteeing a clean termination.
224
+
We'll now start a `Task.Supervisor` process with name `KV.ServerSupervisor`. Keep in mind that the order children are started matters. For example, the acceptor must come last because, if it comes first, it means our application can start accepting requests before the `Task.Supervisor` is running or before we can locate buckets. Shutting down an application will also stop the children in reverse order, guaranteeing a clean termination.
225
225
226
226
Now we need to change `loop_acceptor/1` to use `Task.Supervisor` to serve each request:
Copy file name to clipboardExpand all lines: lib/elixir/pages/references/gradual-set-theoretic-types.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -81,7 +81,7 @@ You can represent all _proper_ lists as `list()`, which also includes the empty
81
81
82
82
You can also specify the type of the list element as argument. For example, `list(integer())` represents the values `[]` and `[1, 2, 3]`, but not `[1, "two", 3]`.
83
83
84
-
Internally, Elixir represents the type `list(a)` as the union two distinct types, `empty_list()` and `not_empty_list(a)`. In other words, `list(integer())` is equivalent to `empty_list() or non_empty_list(integer())`.
84
+
Internally, Elixir represents the type `list(a)` as the union two distinct types, `empty_list()` and `non_empty_list(a)`. In other words, `list(integer())` is equivalent to `empty_list() or non_empty_list(integer())`.
0 commit comments