Skip to content

Commit 6543746

Browse files
authored
Merge pull request #342 from Accenture/341-support-otp23
341 support otp23
2 parents f1b627d + d8e86ad commit 6543746

File tree

34 files changed

+130
-127
lines changed

34 files changed

+130
-127
lines changed

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,3 @@ erl_crash.dump
3939
/.elixir_ls/
4040
*~
4141
*.orig
42-
43-
# asdf
44-
.tool-versions

.tool-versions

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
erlang 23.1.2
2+
elixir 1.11.2-otp-23

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ stages:
1212

1313
.elixir-env: &elixir-env
1414
language: elixir
15-
elixir: "1.10"
16-
otp_release: "22.0"
15+
elixir: "1.11"
16+
otp_release: "23.0"
1717

1818
jobs:
1919
include:

CHANGELOG.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3131
helm repo add accenture https://accenture.github.io/reactive-interaction-gateway
3232
helm install rig accenture/reactive-interaction-gateway
3333
```
34-
34+
3535
More information, follow the [deployment Readme](./deployment/README.md). [#319](https://github.com/Accenture/reactive-interaction-gateway/issues/319)
3636
- make README smaller, easier to read and highlight features. [#284](https://github.com/Accenture/reactive-interaction-gateway/issues/284)
3737

@@ -55,7 +55,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5555

5656
<!-- ### Security -->
5757

58-
<!-- ### Technical Improvements -->
58+
### Technical Improvements
59+
60+
- Updated dependencies to support OTP 23. We've also replaced the versions file with `.tool-versions`, which makes it easier for those using the [asdf package manager](https://asdf-vm.com/) - just run `asdf install` to obtain the correct versions of Erlang and Elixir.
61+
[#341](https://github.com/Accenture/reactive-interaction-gateway/issues/341)
5962
6063
## [2.4.0] - 2020-05-07
6164

Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
FROM elixir:1.10-alpine as build
1+
FROM elixir:1.11-alpine as build
22

33
# Install Elixir & Erlang environment dependencies
44
RUN apk add --no-cache make gcc g++
5+
COPY .tool-versions /opt/sites/rig/
56
RUN mix local.hex --force
67
RUN mix local.rebar --force
78

89
ENV MIX_ENV=prod
910
WORKDIR /opt/sites/rig
1011

1112
# Copy release config
12-
COPY version /opt/sites/rig/
1313
COPY rel /opt/sites/rig/rel/
1414
COPY vm.args /opt/sites/rig/
1515

@@ -28,7 +28,7 @@ COPY lib /opt/sites/rig/lib
2828
RUN mix compile
2929
RUN mix distillery.release
3030

31-
FROM erlang:22-alpine
31+
FROM erlang:23-alpine
3232

3333
LABEL org.label-schema.name="Reactive Interaction Gateway"
3434
LABEL org.label-schema.description="Reactive API Gateway and Event Hub"

aws.dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ WORKDIR /opt/sites/rig/kinesis-client
77
# Compile AWS Kinesis Java application
88
RUN mvn package
99

10-
FROM elixir:1.10-alpine as elixir-build
10+
FROM elixir:1.11-alpine as elixir-build
1111

1212
# Install Elixir & Erlang environment dependencies
1313
RUN apk add --no-cache make gcc g++
14+
COPY .tool-versions /opt/sites/rig/
1415
RUN mix local.hex --force
1516
RUN mix local.rebar --force
1617

1718
ENV MIX_ENV=prod
1819
WORKDIR /opt/sites/rig
1920

2021
# Copy release config
21-
COPY version /opt/sites/rig/
2222
COPY rel /opt/sites/rig/rel/
2323
COPY vm.args /opt/sites/rig/
2424

@@ -37,7 +37,7 @@ COPY lib /opt/sites/rig/lib
3737
RUN mix compile
3838
RUN mix distillery.release
3939

40-
FROM erlang:22-alpine
40+
FROM erlang:23-alpine
4141

4242
RUN apk add --no-cache bash
4343

config/config.exs

+6
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,9 @@ config :rig, RIG.Tracing,
123123
jaeger_service_name: {:system, :charlist, "JAEGER_SERVICE_NAME", 'rig'},
124124
zipkin_address: {:system, :charlist, "ZIPKIN_ADDR", ''},
125125
zipkin_service_name: {:system, "ZIPKIN_SERVICE_NAME", "rig"}
126+
127+
# --------------------------------------
128+
# Phoenix
129+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
130+
131+
config :phoenix, :json_library, Jason

config/rig_api/config.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ config :rig, RigApi.Endpoint,
3737
protocol_options: cowboy_options
3838
],
3939
render_errors: [view: RigApi.ErrorView, accepts: ~w(json)],
40-
pubsub: [name: Rig.PubSub],
40+
pubsub_server: Rig.PubSub,
4141
check_origin: false
4242

4343
# Always start the HTTP endpoints on application startup:

config/rig_inbound_gateway/config.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ config :rig, RigInboundGatewayWeb.Endpoint,
6565
transport_options: ranch_transport_options
6666
],
6767
render_errors: [view: RigInboundGatewayWeb.ErrorView, accepts: ~w(html json xml)],
68-
pubsub: [name: Rig.PubSub],
68+
pubsub_server: Rig.PubSub,
6969
check_origin: false
7070

7171
config :mime, :types, %{

docs/rig-dev-guide.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Developer's Guide to the Reactive Interaction Gateway
44
sidebar_label: Developer's Guide
55
---
66

7-
You'd like to mess with the code? Great! To get started, install Elixir and the Mix build tool on your machine. You can either follow the [instructions on the Elixir website](https://elixir-lang.org/install.html), or use [kiex](https://github.com/taylor/kiex) to install and manage Elixir runtimes. Kiex is recommended for development, because it allows you to jump to definitions inside the Elixir source code, plus you can checkout upcoming Elixir versions easily.
7+
You'd like to help hacking? Great! To get started, install Elixir and the Mix build tool on your machine. If you use [asdf](https://asdf-vm.com/), all you need to do is `asdf install`. Otherwise, either follow the [instructions on the Elixir website](https://elixir-lang.org/install.html), or use [kiex](https://github.com/taylor/kiex) to install and manage Elixir runtimes.
88

99
With Elixir installed, do this:
1010

@@ -38,11 +38,11 @@ To have the project use a newer Elixir version, make sure to change the followin
3838

3939
- `.travis.yml`: Update the Elixir and OTP versions in the `.elixir-env` section.
4040
- `Dockerfile`, `aws.dockerfile`, `smoke_tests.dockerfile`: Make sure to change the `FROM` image tag for both the build image (elixir:...-alpine) as well as the runtime image (erlang:...-alpine). If the Erlang runtime (ERTS) in the runtime image doesn't match the ERTS version in the build image, chances are the built image won't work due to missing libraries. Because of this, it's best to use the most recent versions for both images when upgrading - they should always be compatible.
41-
- `version`: Again, make sure both the Elixir and the OTP versions match what you have used in the previous steps.
41+
- `.tool-versions`: Again, make sure both the Elixir and the OTP versions match what you have used in the previous steps.
4242

4343
## Releasing a new version
4444

45-
- Increment `rig` version in the [version](../version) file
45+
- Increment `@rig_version` in [mix.exs](../mix.exs)
4646
- Increment `appVersion` in the [Helm v2 Chart.yaml](../deployment/reactive-interaction-gateway/Chart.yaml) and [Helm v3 Chart.yaml](../deployment/reactive-interaction-gateway/Chart.yaml) files
4747
- Update Helm chart README files: install [helm-docs](https://github.com/norwoodj/helm-docs) and run `helm-docs` in the root directory
4848
- Increment image tag in the [Kubernetes rig.yaml](../deployment/kubectl/rig.yaml) file

lib/rig/application.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ defmodule Rig.Application do
1818
Discovery.start()
1919

2020
children = [
21-
Spec.supervisor(Phoenix.PubSub.PG2, [Rig.PubSub, []]),
21+
{Phoenix.PubSub, name: Rig.PubSub},
2222
# Kafka:
2323
{DynamicSupervisor, strategy: :one_for_one, name: RigKafka.DynamicSupervisor},
2424
# Event stream handling:

lib/rig/distributed_set.ex

+7-9
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ defmodule RIG.DistributedSet do
124124
{:ok, %{state | ets_table: ets_table}}
125125
end
126126

127-
@doc "Handles get_record requests from other nodes."
127+
# Handles get_record requests from other nodes.
128128
@impl GenServer
129129
def handle_call(
130130
{:get_records, since_record_id},
@@ -163,7 +163,7 @@ defmodule RIG.DistributedSet do
163163
{:reply, reply, state}
164164
end
165165

166-
@doc "Handles adding a record on this node."
166+
# Handles adding a record on this node.
167167
@impl GenServer
168168
def handle_call(
169169
{:add_from_local, {_, uuid, _, _} = record},
@@ -211,12 +211,10 @@ defmodule RIG.DistributedSet do
211211
{:noreply, %{state | last_record_id: synced_record_id}}
212212
end
213213

214-
@doc """
215-
Asks a random peer for missing records.
216-
217-
Records are missing on startup, but there could also be a gap caused by a temporary
218-
network split.
219-
"""
214+
# Asks a random peer for missing records.
215+
#
216+
# Records are missing on startup, but there could also be a gap caused by a temporary
217+
# network split.
220218
@impl GenServer
221219
def handle_info(
222220
:sync_with_random_peer,
@@ -241,7 +239,7 @@ defmodule RIG.DistributedSet do
241239
{:noreply, state}
242240
end
243241

244-
@doc "Remove expired records."
242+
# Remove expired records.
245243
@impl GenServer
246244
def handle_info(:cleanup, %{ets_table: ets_table} = state) do
247245
remove_expired_records(ets_table)

lib/rig_api/router.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ defmodule RigApi.Router do
66
parsers: [:urlencoded, :multipart, :json],
77
# return "415 Unsupported Media Type" if not handled by any parser
88
pass: [],
9-
json_decoder: Poison
9+
json_decoder: Jason
1010
)
1111
end
1212

lib/rig_cloud_events/cloud_event.ex

+6-8
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,12 @@ defmodule RigCloudEvents.CloudEvent do
3838
end
3939
end
4040

41-
@doc """
42-
Convenience function used in testing.
43-
44-
If this would be called in production, of course it would be way more efficient to
45-
access the given map directly. However, this modules' raison d'être is the safe
46-
handling of incoming JSON encoded data, so it's safe to assume this function is ever
47-
only called by tests.
48-
"""
41+
# Convenience function used in testing.
42+
#
43+
# If this would be called in production, of course it would be way more efficient to
44+
# access the given map directly. However, this modules' raison d'être is the safe
45+
# handling of incoming JSON encoded data, so it's safe to assume this function is ever
46+
# only called by tests.
4947
@spec parse(map) :: {:ok, t} | {:error, any}
5048
def parse(map) when is_map(map) do
5149
map |> Jason.encode!() |> parse

lib/rig_inbound_gateway/api_proxy/handler.ex

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ defmodule RigInboundGateway.ApiProxy.Handler do
77
alias RigInboundGateway.ApiProxy.Api
88

99
@type request_path :: String.t()
10-
@callback handle_http_request(Conn.t(), Api.t(), Api.endpoint(), request_path) ::
11-
:ok | {:error, any}
10+
@callback handle_http_request(Conn.t(), Api.t(), Api.endpoint(), request_path) :: Conn.t()
1211
end

lib/rig_inbound_gateway/api_proxy/handler/kafka.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ defmodule RigInboundGateway.ApiProxy.Handler.Kafka do
5959
@impl Handler
6060
def handle_http_request(conn, api, endpoint, request_path)
6161

62-
@doc "CORS response for preflight request."
62+
# CORS response for preflight request.
6363
def handle_http_request(
6464
%{method: "OPTIONS"} = conn,
6565
_,
@@ -139,7 +139,7 @@ defmodule RigInboundGateway.ApiProxy.Handler.Kafka do
139139
query: conn.query_string
140140
})
141141
|> Tracing.append_context(Tracing.context())
142-
|> Poison.encode!()
142+
|> Jason.encode!()
143143

144144
produce(partition, kafka_message, topic, schema)
145145

lib/rig_inbound_gateway/api_proxy/handler/kinesis.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ defmodule RigInboundGateway.ApiProxy.Handler.Kinesis do
5555
@impl Handler
5656
def handle_http_request(conn, api, endpoint, request_path)
5757

58-
@doc "CORS response for preflight request."
58+
# CORS response for preflight request.
5959
def handle_http_request(
6060
%{method: "OPTIONS"} = conn,
6161
_,
@@ -125,7 +125,7 @@ defmodule RigInboundGateway.ApiProxy.Handler.Kinesis do
125125
query: conn.query_string
126126
})
127127
|> Tracing.append_context(Tracing.context())
128-
|> Poison.encode!()
128+
|> Jason.encode!()
129129

130130
produce(partition, kinesis_message, topic)
131131

lib/rig_inbound_gateway/api_proxy/handler/nats.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ defmodule RigInboundGateway.ApiProxy.Handler.Nats do
2323
@doc @help_text
2424
def handle_http_request(conn, api, endpoint, request_path)
2525

26-
@doc "CORS response for preflight request."
26+
# CORS response for preflight request.
2727
def handle_http_request(%{method: "OPTIONS"} = conn, _, %{"target" => "nats"} = _endpoint, _) do
2828
conn
2929
|> with_cors()

lib/rig_inbound_gateway/api_proxy/presence_handler.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ defmodule RigInboundGateway.ApiProxy.PresenceHandler do
1010
1111
"""
1212
require Logger
13-
@behaviour Phoenix.Tracker
13+
use Phoenix.Tracker
1414

1515
alias RigInboundGateway.Proxy
1616

lib/rig_inbound_gateway/api_proxy/serializer.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ defmodule RigInboundGateway.ApiProxy.Serializer do
2323
end
2424

2525
def encode_error_message(message) do
26-
Poison.encode!(%{message: message})
26+
Jason.encode!(%{message: message})
2727
end
2828
end

lib/rig_inbound_gateway/api_proxy/sup.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ defmodule RigInboundGateway.ApiProxy.Sup do
1212

1313
def init(:ok) do
1414
children = [
15-
worker(RigInboundGateway.ApiProxy.PresenceHandler, _args = [[pubsub_server: Rig.PubSub]])
15+
{RigInboundGateway.ApiProxy.PresenceHandler, [pubsub_server: Rig.PubSub]}
1616
]
1717

1818
Supervisor.init(children, strategy: :one_for_one)

lib/rig_inbound_gateway/request_logger/kafka.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ defmodule RigInboundGateway.RequestLogger.Kafka do
5656
}
5757
}
5858
|> Tracing.append_context(Tracing.context())
59-
|> Poison.encode!()
59+
|> Jason.encode!()
6060

6161
produce("partition", kafka_message)
6262
end

lib/rig_inbound_gateway_web/v1/sse.ex

+4-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ defmodule RigInboundGatewayWeb.V1.SSE do
5050

5151
{:error, reason} ->
5252
req = :cowboy_req.reply(400, %{}, reason, req)
53-
{:stop, req, :unknown_state}
53+
# Returning :ok at this point simply closes the handler.
54+
{:ok, req, :unknown_state}
5455
end
5556
end
5657

@@ -84,7 +85,8 @@ defmodule RigInboundGatewayWeb.V1.SSE do
8485

8586
on_error = fn reason ->
8687
req = :cowboy_req.reply(400, %{}, reason, req)
87-
{:stop, req, :no_state}
88+
# Returning :ok at this point simply closes the handler.
89+
{:ok, req, :no_state}
8890
end
8991

9092
ConnectionInit.set_up(

lib/rig_inbound_gateway_web/v1/websocket.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ defmodule RigInboundGatewayWeb.V1.Websocket do
9696

9797
# ---
9898

99-
@doc ~S"The client may send this as the response to the :ping heartbeat."
99+
# The client may send this as the response to the :ping heartbeat.
100100
@impl :cowboy_websocket
101101
def websocket_handle({:pong, _app_data}, state), do: {:ok, state, :hibernate}
102102
@impl :cowboy_websocket
103103
def websocket_handle(:pong, state), do: {:ok, state, :hibernate}
104104

105-
@doc ~S"Allow the client to send :ping messages to test connectivity."
105+
# Allow the client to send :ping messages to test connectivity.
106106
@impl :cowboy_websocket
107107
def websocket_handle({:ping, app_data}, _state), do: {:reply, {:pong, app_data}, :hibernate}
108108

lib/rig_outbound_gateway/kinesis/java_client.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ defmodule RigOutboundGateway.Kinesis.JavaClient do
117117
@spec java_client_callback(data :: [{atom(), String.t()}, ...]) :: :ok
118118
def java_client_callback(data) do
119119
data[:body]
120-
|> Poison.decode!()
120+
|> Jason.decode!()
121121
|> KinesisToFilter.kinesis_handler()
122122
end
123123
end

0 commit comments

Comments
 (0)