Skip to content

Commit 9b7be08

Browse files
author
José Valim
committed
Release v0.14.0
1 parent 2d3dd2e commit 9b7be08

File tree

12 files changed

+122
-138
lines changed

12 files changed

+122
-138
lines changed

.travis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
language: elixir
22
elixir:
3-
- 1.3.4
4-
- 1.4.5
53
- 1.5.1
4+
- 1.6.5
65
sudo: false # to use faster container based build environment
76
notifications:
87
recipients:
98
109
otp_release:
11-
- 18.0
1210
- 19.3
1311
- 20.0
1412
script:

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## v0.14.0 (2018-06-10)
4+
5+
This version requires Elixir v1.5+.
6+
7+
### Bug fixes
8+
9+
* Ensure a `:producer_consumer` stops asking the producer if downstream demand is 0
10+
* Enforce the :hash option for non-int partitions in PartitionDispatcher
11+
312
## v0.13.1 (2018-01-28)
413

514
Note: this is the last version to support Elixir v1.3 and v1.4.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ Examples for using GenStage and ConsumerSupervisor can be found [examples](examp
2424

2525
## Installation
2626

27-
GenStage requires Elixir v1.3. Just add `:gen_stage` to your list of dependencies in mix.exs:
27+
GenStage requires Elixir v1.5. Just add `:gen_stage` to your list of dependencies in mix.exs:
2828

2929
```elixir
3030
def deps do
31-
[{:gen_stage, "~> 0.13"}]
31+
[{:gen_stage, "~> 0.14"}]
3232
end
3333
```
3434

lib/consumer_supervisor.ex

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -118,21 +118,19 @@ defmodule ConsumerSupervisor do
118118
@behaviour ConsumerSupervisor
119119
import Supervisor.Spec
120120

121-
if Code.ensure_loaded?(Supervisor) and function_exported?(Supervisor, :init, 2) do
122-
@doc false
123-
def child_spec(arg) do
124-
default = %{
125-
id: __MODULE__,
126-
start: {__MODULE__, :start_link, [arg]},
127-
type: :supervisor
128-
}
129-
130-
Supervisor.child_spec(default, unquote(Macro.escape(opts)))
131-
end
121+
@doc false
122+
def child_spec(arg) do
123+
default = %{
124+
id: __MODULE__,
125+
start: {__MODULE__, :start_link, [arg]},
126+
type: :supervisor
127+
}
132128

133-
defoverridable child_spec: 1
129+
Supervisor.child_spec(default, unquote(Macro.escape(opts)))
134130
end
135131

132+
defoverridable child_spec: 1
133+
136134
@doc false
137135
def init(arg)
138136
end
@@ -191,8 +189,8 @@ defmodule ConsumerSupervisor do
191189
name. The supported values are described under the "Name Registration"
192190
section in the `GenServer` module docs.
193191
"""
194-
@spec start_link(module, any) :: Supervisor.on_start
195-
@spec start_link(module, any, [option]) :: Supervisor.on_start
192+
@spec start_link(module, any) :: Supervisor.on_start()
193+
@spec start_link(module, any, [option]) :: Supervisor.on_start()
196194
def start_link(mod, args, opts \\ []) do
197195
GenStage.start_link(__MODULE__, {mod, args, opts[:name]}, opts)
198196
end
@@ -314,16 +312,9 @@ defmodule ConsumerSupervisor do
314312
{:ok, [template], opts}
315313
end
316314

317-
if Code.ensure_loaded?(Supervisor) and function_exported?(Supervisor, :init, 2) do
318-
def init([template], opts) when is_tuple(template) or is_map(template) or is_atom(template) do
319-
{:ok, {_, [template]}} = Supervisor.init([template], opts)
320-
{:ok, [template], opts}
321-
end
322-
end
323-
324-
def init(not_a_list, opts) when not is_list(not_a_list) do
325-
IO.warn("ConsumerSupervisor.init/1 expects a list with a single element")
326-
init([not_a_list], opts)
315+
def init([template], opts) when is_tuple(template) or is_map(template) or is_atom(template) do
316+
{:ok, {_, [template]}} = Supervisor.init([template], opts)
317+
{:ok, [template], opts}
327318
end
328319

329320
@compile {:inline, call: 2}

lib/gen_stage.ex

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,19 +1118,17 @@ defmodule GenStage do
11181118
quote location: :keep, bind_quoted: [opts: opts] do
11191119
@behaviour GenStage
11201120

1121-
if Code.ensure_loaded?(Supervisor) and function_exported?(Supervisor, :init, 2) do
1122-
@doc false
1123-
def child_spec(arg) do
1124-
default = %{
1125-
id: __MODULE__,
1126-
start: {__MODULE__, :start_link, [arg]}
1127-
}
1128-
1129-
Supervisor.child_spec(default, unquote(Macro.escape(opts)))
1130-
end
1131-
1132-
defoverridable child_spec: 1
1121+
@doc false
1122+
def child_spec(arg) do
1123+
default = %{
1124+
id: __MODULE__,
1125+
start: {__MODULE__, :start_link, [arg]}
1126+
}
1127+
1128+
Supervisor.child_spec(default, unquote(Macro.escape(opts)))
11331129
end
1130+
1131+
defoverridable child_spec: 1
11341132
end
11351133
end
11361134

lib/gen_stage/buffer.ex

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ defmodule GenStage.Buffer do
77
# is stored in a wheel for performance and to avoid discards.
88
@moduledoc false
99

10-
@opaque t() :: {:queue.queue, non_neg_integer(), wheel()}
10+
@opaque t() :: {:queue.queue(), non_neg_integer(), wheel()}
1111
@typep wheel() :: {non_neg_integer(), pos_integer(), map()} | pos_integer() | reference()
1212

1313
@doc """
@@ -175,20 +175,17 @@ defmodule GenStage.Buffer do
175175
defp pop_and_increment_wheel({pos, max, wheel}) do
176176
new_pos = rem(pos + 1, max)
177177

178-
# TODO: Use :maps.take/2
179-
case wheel do
180-
%{^pos => perms} when map_size(wheel) == 1 ->
181-
{:ok, perms, max}
178+
case :maps.take(pos, wheel) do
179+
{perms, wheel} ->
180+
maybe_triplet = if wheel == %{}, do: max, else: {new_pos, max, wheel}
181+
{:ok, perms, maybe_triplet}
182182

183-
%{^pos => perms} ->
184-
{:ok, perms, {new_pos, max, Map.delete(wheel, pos)}}
185-
186-
%{} ->
183+
:error ->
187184
{:error, {new_pos, max, wheel}}
188185
end
189186
end
190187

191188
defp pop_and_increment_wheel(max) do
192189
{:error, max}
193190
end
194-
end
191+
end

lib/gen_stage/stream.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ defmodule GenStage.Stream do
1414

1515
defp stream_validate_opts({to, opts}) when is_list(opts) do
1616
with {:ok, max, _} <- Utils.validate_integer(opts, :max_demand, 1000, 1, :infinity, false),
17-
{:ok, min, _} <- Utils.validate_integer(opts, :min_demand, div(max, 2), 0, max - 1, false),
17+
{:ok, min, _} <-
18+
Utils.validate_integer(opts, :min_demand, div(max, 2), 0, max - 1, false),
1819
{:ok, cancel, _} <-
1920
Utils.validate_in(opts, :cancel, :permanent, [:temporary, :transient, :permanent]) do
2021
{to, cancel, min, max, opts}

lib/gen_stage/utils.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,4 @@ defmodule GenStage.Utils do
135135
defp split_events([event | events], limit, counter, acc) do
136136
split_events(events, limit, counter + 1, [event | acc])
137137
end
138-
end
138+
end

mix.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
defmodule GenStage.Mixfile do
22
use Mix.Project
33

4-
@version "0.13.1"
4+
@version "0.14.0"
55

66
def project do
77
[
88
app: :gen_stage,
99
version: @version,
10-
elixir: "~> 1.3",
10+
elixir: "~> 1.5",
1111
package: package(),
1212
description: "Producer and consumer pipelines with back-pressure for Elixir",
1313
start_permanent: Mix.env() == :prod,

mix.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%{
2-
"earmark": {:hex, :earmark, "1.2.4", "99b637c62a4d65a20a9fb674b8cffb8baa771c04605a80c911c4418c69b75439", [:mix], [], "hexpm"},
3-
"ex_doc": {:hex, :ex_doc, "0.18.1", "37c69d2ef62f24928c1f4fdc7c724ea04aecfdf500c4329185f8e3649c915baf", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"},
2+
"earmark": {:hex, :earmark, "1.2.5", "4d21980d5d2862a2e13ec3c49ad9ad783ffc7ca5769cf6ff891a4553fbaae761", [:mix], [], "hexpm"},
3+
"ex_doc": {:hex, :ex_doc, "0.18.3", "f4b0e4a2ec6f333dccf761838a4b253d75e11f714b85ae271c9ae361367897b7", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"},
44
"inch_ex": {:hex, :inch_ex, "0.5.5", "b63f57e281467bd3456461525fdbc9e158c8edbe603da6e3e4671befde796a3d", [:mix], [{:poison, "~> 1.5 or ~> 2.0 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
55
"poison": {:hex, :poison, "3.0.0", "625ebd64d33ae2e65201c2c14d6c85c27cc8b68f2d0dd37828fde9c6920dd131", [:mix], [], "hexpm"},
66
}

0 commit comments

Comments
 (0)