Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

341 support otp23 #342

Merged
merged 9 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,3 @@ erl_crash.dump
/.elixir_ls/
*~
*.orig

# asdf
.tool-versions
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
erlang 23.1.2
elixir 1.11.2-otp-23
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ stages:

.elixir-env: &elixir-env
language: elixir
elixir: "1.10"
otp_release: "22.0"
elixir: "1.11"
otp_release: "23.0"

jobs:
include:
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
FROM elixir:1.10-alpine as build
FROM elixir:1.11-alpine as build

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

ENV MIX_ENV=prod
WORKDIR /opt/sites/rig

# Copy release config
COPY version /opt/sites/rig/
COPY rel /opt/sites/rig/rel/
COPY vm.args /opt/sites/rig/

Expand All @@ -28,7 +28,7 @@ COPY lib /opt/sites/rig/lib
RUN mix compile
RUN mix distillery.release

FROM erlang:22-alpine
FROM erlang:23-alpine

LABEL org.label-schema.name="Reactive Interaction Gateway"
LABEL org.label-schema.description="Reactive API Gateway and Event Hub"
Expand Down
6 changes: 3 additions & 3 deletions aws.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ WORKDIR /opt/sites/rig/kinesis-client
# Compile AWS Kinesis Java application
RUN mvn package

FROM elixir:1.10-alpine as elixir-build
FROM elixir:1.11-alpine as elixir-build

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

ENV MIX_ENV=prod
WORKDIR /opt/sites/rig

# Copy release config
COPY version /opt/sites/rig/
COPY rel /opt/sites/rig/rel/
COPY vm.args /opt/sites/rig/

Expand All @@ -37,7 +37,7 @@ COPY lib /opt/sites/rig/lib
RUN mix compile
RUN mix distillery.release

FROM erlang:22-alpine
FROM erlang:23-alpine

RUN apk add --no-cache bash

Expand Down
6 changes: 6 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,9 @@ config :rig, RIG.Tracing,
jaeger_service_name: {:system, :charlist, "JAEGER_SERVICE_NAME", 'rig'},
zipkin_address: {:system, :charlist, "ZIPKIN_ADDR", ''},
zipkin_service_name: {:system, "ZIPKIN_SERVICE_NAME", "rig"}

# --------------------------------------
# Pheonix
kevinbader marked this conversation as resolved.
Show resolved Hide resolved
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

config :phoenix, :json_library, Jason
2 changes: 1 addition & 1 deletion config/rig_api/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ config :rig, RigApi.Endpoint,
protocol_options: cowboy_options
],
render_errors: [view: RigApi.ErrorView, accepts: ~w(json)],
pubsub: [name: Rig.PubSub],
pubsub_server: Rig.PubSub,
check_origin: false

# Always start the HTTP endpoints on application startup:
Expand Down
2 changes: 1 addition & 1 deletion config/rig_inbound_gateway/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ config :rig, RigInboundGatewayWeb.Endpoint,
transport_options: ranch_transport_options
],
render_errors: [view: RigInboundGatewayWeb.ErrorView, accepts: ~w(html json xml)],
pubsub: [name: Rig.PubSub],
pubsub_server: Rig.PubSub,
check_origin: false

config :mime, :types, %{
Expand Down
6 changes: 3 additions & 3 deletions docs/rig-dev-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Developer's Guide to the Reactive Interaction Gateway
sidebar_label: Developer's Guide
---

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.
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.

With Elixir installed, do this:

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

- `.travis.yml`: Update the Elixir and OTP versions in the `.elixir-env` section.
- `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.
- `version`: Again, make sure both the Elixir and the OTP versions match what you have used in the previous steps.
- `.tool-versions`: Again, make sure both the Elixir and the OTP versions match what you have used in the previous steps.

## Releasing a new version

- Increment `rig` version in the [version](../version) file
- Increment `@rig_version` in [mix.exs](../mix.exs)
- 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
- Update Helm chart README files: install [helm-docs](https://github.com/norwoodj/helm-docs) and run `helm-docs` in the root directory
- Increment image tag in the [Kubernetes rig.yaml](../deployment/kubectl/rig.yaml) file
Expand Down
2 changes: 1 addition & 1 deletion lib/rig/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule Rig.Application do
Discovery.start()

children = [
Spec.supervisor(Phoenix.PubSub.PG2, [Rig.PubSub, []]),
{Phoenix.PubSub, name: Rig.PubSub},
# Kafka:
{DynamicSupervisor, strategy: :one_for_one, name: RigKafka.DynamicSupervisor},
# Event stream handling:
Expand Down
2 changes: 1 addition & 1 deletion lib/rig_api/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ defmodule RigApi.Router do
parsers: [:urlencoded, :multipart, :json],
# return "415 Unsupported Media Type" if not handled by any parser
pass: [],
json_decoder: Poison
json_decoder: Jason
)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rig_inbound_gateway/api_proxy/handler/kafka.ex
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ defmodule RigInboundGateway.ApiProxy.Handler.Kafka do
query: conn.query_string
})
|> Tracing.append_context(Tracing.context())
|> Poison.encode!()
|> Jason.encode!()

produce(partition, kafka_message, topic, schema)

Expand Down
2 changes: 1 addition & 1 deletion lib/rig_inbound_gateway/api_proxy/handler/kinesis.ex
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ defmodule RigInboundGateway.ApiProxy.Handler.Kinesis do
query: conn.query_string
})
|> Tracing.append_context(Tracing.context())
|> Poison.encode!()
|> Jason.encode!()

produce(partition, kinesis_message, topic)

Expand Down
2 changes: 1 addition & 1 deletion lib/rig_inbound_gateway/api_proxy/serializer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ defmodule RigInboundGateway.ApiProxy.Serializer do
end

def encode_error_message(message) do
Poison.encode!(%{message: message})
Jason.encode!(%{message: message})
end
end
2 changes: 1 addition & 1 deletion lib/rig_inbound_gateway/request_logger/kafka.ex
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ defmodule RigInboundGateway.RequestLogger.Kafka do
}
}
|> Tracing.append_context(Tracing.context())
|> Poison.encode!()
|> Jason.encode!()

produce("partition", kafka_message)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rig_outbound_gateway/kinesis/java_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ defmodule RigOutboundGateway.Kinesis.JavaClient do
@spec java_client_callback(data :: [{atom(), String.t()}, ...]) :: :ok
def java_client_callback(data) do
data[:body]
|> Poison.decode!()
|> Jason.decode!()
|> KinesisToFilter.kinesis_handler()
end
end
26 changes: 13 additions & 13 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ defmodule RIG.MixProject do
from backend services to connected frontends (and vice versa).
"""

@rig_version "3.0.0-alpha.1"

def project do
%{rig: rig_version, elixir: elixir_version} = versions()
elixir_version = elixir_version_from_tool_versions_file()

[
# OTP app:
Expand All @@ -17,7 +19,7 @@ defmodule RIG.MixProject do
# Meta data:
name: "Reactive Interaction Gateway",
description: @description,
version: rig_version,
version: @rig_version,
source_url: "https://github.com/Accenture/reactive-interaction-gateway",
homepage_url: "https://accenture.github.io/reactive-interaction-gateway",
docs: docs(),
Expand All @@ -44,6 +46,11 @@ defmodule RIG.MixProject do
]
end

defp elixir_version_from_tool_versions_file do
[_, version] = Regex.run(~r/^elixir (.+)-otp-\d+$/m, File.read!(".tool-versions"))
version
end

defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]

Expand All @@ -70,11 +77,6 @@ defmodule RIG.MixProject do
]
end

defp versions do
{map, []} = Code.eval_file("version", ".")
map
end

defp docs do
[
# Website and documentation is built off master,
Expand Down Expand Up @@ -116,17 +118,15 @@ defmodule RIG.MixProject do
# Read and use application configuration from environment variables:
{:confex, "~> 3.4"},
# For providing the global Phx PubSub server:
{:phoenix_pubsub, "~> 1.1"},
{:phoenix_pubsub, "~> 2.0"},
# for Kafka, partition from MurmurHash(key):
{:murmur, "~> 1.0"},
{:peerage, "~> 1.0"},
# For running external commands in Mix tasks:
{:porcelain, "~> 2.0"},
# HTTP request handling (wraps Cowboy):
{:plug, "~> 1.9"},
# JSON parser, for cloud_event and event_hub:
{:poison, "~> 3.0 or ~> 4.0"},
# JSON parser that's supposedly faster than poison:
# JSON parser:
{:jason, "~> 1.2"},
{:jaxon, "~> 1.0"},
# JSON Pointer (RFC 6901) implementation for subscriptions:
Expand All @@ -152,7 +152,7 @@ defmodule RIG.MixProject do
# For JSON Web Tokens:
{:joken, "~> 1.5"},
# Web framework, for all HTTP endpoints except SSE and WS:
{:phoenix, "~> 1.4"},
{:phoenix, "~> 1.5"},
{:plug_cowboy, "~> 2.1"},
{:phoenix_swagger, "~> 0.8"},
# Data validation library, e.g. used for proxy configuration:
Expand All @@ -179,7 +179,7 @@ defmodule RIG.MixProject do
{:opencensus_jaeger, "~> 0.0.1"},
{:opencensus_zipkin, "~> 0.3"},
# NATS client:
{:gnat, "~> 1.0.0"}
{:gnat, "~> 1.0"}
]
end

Expand Down
Loading