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

Migrate to Elixir 1.18 #227

Merged
merged 8 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 6 additions & 6 deletions .github/workflows/core-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
elixir: [1.14]
otp: [25]
elixir: [1.18]
otp: [27]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -72,8 +72,8 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04]
elixir: [1.14]
otp: [25]
elixir: [1.18]
otp: [27]

runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -118,8 +118,8 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04]
elixir: [1.14]
otp: [25]
elixir: [1.18]
otp: [27]

runs-on: ${{ matrix.os }}
services:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dialyzer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
elixir: [1.14]
otp: [25]
elixir: [1.18]
otp: [27]
working-directory: [core, worker]

defaults:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/worker-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
elixir: [1.14]
otp: [25]
elixir: [1.18]
otp: [27]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -72,8 +72,8 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04]
elixir: [1.14]
otp: [25]
elixir: [1.18]
otp: [27]

runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -110,4 +110,4 @@ jobs:
mix do deps.get, deps.compile

- name: Run Worker Tests
run: mix test
run: mix test
2 changes: 1 addition & 1 deletion core/config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import Config

# Print only errors during test, add :console to print logs
config :logger, level: :warn, backends: []
config :logger, level: :warning, backends: []

# --- Core Configs ---
config :core, Core.Domain.Ports.Commands, adapter: Core.Commands.Mock
Expand Down
19 changes: 7 additions & 12 deletions core/lib/core/adapters/connectors/event_connectors/mqtt.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ defmodule Core.Adapters.Connectors.EventConnectors.Mqtt do
|> Map.put(:module, module)}

{:error, err} ->
Logger.warn("MQTT Event Connector failed to start with error: #{inspect(err)}")
Logger.warning("MQTT Event Connector failed to start with error: #{inspect(err)}")
{:stop, :normal}

other ->
Logger.warn("MQTT Event Connector failed to start with reason: #{inspect(other)}")
Logger.warning("MQTT Event Connector failed to start with reason: #{inspect(other)}")
{:stop, :normal}
end

Expand All @@ -75,21 +75,16 @@ defmodule Core.Adapters.Connectors.EventConnectors.Mqtt do
Logger.info("MQTT Event Connector: #{module}/#{function} invoked with res #{inspect(res)}")
else
{:error, err} ->
Logger.warn(
Logger.warning(
"MQTT Event Connector: invocation of #{module}/#{function} failed with error #{inspect(err)}"
)

other ->
Logger.warn(
"MQTT Event Connector: invocation of #{module}/#{function} failed with cause #{inspect(other)}"
)
end

{:noreply, params}
end

def handle_info({:disconnect, _reason, _props}, params) do
Logger.warn(
Logger.warning(
"MQTT Event Connector (host #{params.host}, port #{params.port}, topic #{params.topic}): disconnected from broker"
)

Expand All @@ -99,13 +94,13 @@ defmodule Core.Adapters.Connectors.EventConnectors.Mqtt do
{:noreply, params |> Map.put(:pid, pid)}

_ ->
Logger.warn("MQTT Event Connector: reconnect failed, killing Connector")
Logger.warning("MQTT Event Connector: reconnect failed, killing Connector")
{:stop, :normal, params}
end
end

def handle_info({:EXIT, pid, reason}, %{pid: pid} = params) do
Logger.warn(
Logger.warning(
"MQTT Event Connector (host #{params.host}, port #{params.port}, topic #{params.topic}): emqtt process died with reason #{inspect(reason)}"
)

Expand All @@ -115,7 +110,7 @@ defmodule Core.Adapters.Connectors.EventConnectors.Mqtt do
{:noreply, params |> Map.put(:pid, pid)}

_ ->
Logger.warn("MQTT Event Connector: emqtt process restart failed, killing Connector")
Logger.warning("MQTT Event Connector: emqtt process restart failed, killing Connector")
{:stop, :normal, params}
end
end
Expand Down
7 changes: 4 additions & 3 deletions core/lib/core/adapters/data_sinks/couchdb.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,17 @@ defmodule Core.Adapters.DataSinks.CouchDB do
response =
:httpc.request(
:post,
{url, [{'Authorization', 'Basic ' ++ :base64.encode_to_string('#{user}:#{pass}')}],
'application/json', json},
{url,
[{~c"Authorization", ~c"Basic " ++ :base64.encode_to_string(~c"#{user}:#{pass}")}],
~c"application/json", json},
[],
[]
)

Logger.debug("CouchDB Sink: response: #{inspect(response)}")

{:error, reason} ->
Logger.warn("CouchDB Sink: failed to encode result into JSON: #{reason}")
Logger.warning("CouchDB Sink: failed to encode result into JSON: #{reason}")
end

{:noreply, state}
Expand Down
2 changes: 1 addition & 1 deletion core/lib/core/adapters/telemetry/collector.ex
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ defmodule Core.Adapters.Telemetry.Collector do
save_metrics(worker, metrics)

{:error, reason} ->
Logger.warn("Metrics Collector: error pulling metrics #{inspect(reason)}")
Logger.warning("Metrics Collector: error pulling metrics #{inspect(reason)}")
end

Process.send_after(self(), :pull, 5_000)
Expand Down
6 changes: 3 additions & 3 deletions core/lib/core/adapters/telemetry/monitor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ defmodule Core.Adapters.Telemetry.Monitor do

@impl true
def handle_info({:nodeup, node}, dynamic_supervisor) do
if is_worker(node) do
if worker?(node) do
_ =
DynamicSupervisor.start_child(
dynamic_supervisor,
Expand Down Expand Up @@ -87,11 +87,11 @@ defmodule Core.Adapters.Telemetry.Monitor do

case DynamicSupervisor.terminate_child(sup, pid) do
:ok -> Logger.info("Worker Nodes Monitor: monitoring of #{node} stopped")
{:error, _} -> Logger.warn("Worker Nodes Monitor: monitoring of #{node} already stopped")
{:error, _} -> Logger.warning("Worker Nodes Monitor: monitoring of #{node} already stopped")
end
end

defp is_worker(node) do
defp worker?(node) do
node |> Atom.to_string() |> String.contains?("worker")
end
end
2 changes: 1 addition & 1 deletion core/lib/core/domain/invoker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ defmodule Core.Domain.Invoker do
@spec invoke_with_code(atom(), pid(), InvokeParams.t(), FunctionStruct.t()) ::
{:ok, InvokeResult.t()} | {:error, {:exec_error, any()}}
def invoke_with_code(worker, handler, _, func) do
Logger.warn("Invoker: function not available in worker, re-invoking with code")
Logger.warning("Invoker: function not available in worker, re-invoking with code")
Commands.send_invoke_with_code(worker, handler, func)
end

Expand Down
6 changes: 3 additions & 3 deletions core/lib/core/domain/policies/app.ex
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ defimpl Core.Domain.Policies.SchedulingPolicy, for: Data.Configurations.APP do
end
end)
|> Enum.filter(fn w ->
is_valid?(w, function, invalidate_capacity, invalidate_invocations)
valid?(w, function, invalidate_capacity, invalidate_invocations)
end)

case filtered_workers do
Expand Down Expand Up @@ -188,13 +188,13 @@ defimpl Core.Domain.Policies.SchedulingPolicy, for: Data.Configurations.APP do
- true if the worker can host the function, given the conditions
- false otherwise
"""
@spec is_valid?(
@spec valid?(
Data.Worker.t(),
Data.FunctionStruct.t(),
number() | :infinity,
number() | :infinity
) :: boolean
def is_valid?(
def valid?(
%Data.Worker{
concurrent_functions: c,
resources: %Data.Worker.Metrics{
Expand Down
2 changes: 1 addition & 1 deletion core/lib/core/domain/scheduler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ defmodule Core.Domain.Scheduler do
def select(workers, function, config, args \\ %{})

def select([], _, _, _args) do
Logger.warn("Scheduler: tried selection with NO workers")
Logger.warning("Scheduler: tried selection with NO workers")
{:error, :no_workers}
end

Expand Down
15 changes: 8 additions & 7 deletions core/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defmodule Core.MixProject do
[
app: :core,
version: "0.9.0",
elixir: "~> 1.14",
elixir: "~> 1.18",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
dialyzer: [
Expand Down Expand Up @@ -50,25 +50,26 @@ defmodule Core.MixProject do
# Specifies your project dependencies.
#
# Type `mix help deps` for examples and options.
# TODO: update deps
defp deps do
[
{:data, path: "../data"},
# prod deps
{:phoenix, "~> 1.7.2"},
{:phoenix_ecto, "~> 4.4"},
{:phoenix_live_dashboard, "~> 0.7.2"},
{:phoenix_live_dashboard, "~> 0.8"},
{:ecto_sql, "~> 3.6"},
{:postgrex, ">= 0.0.0"},
{:jason, "~> 1.3"},
{:libcluster, "~> 3.3"},
{:libcluster, "~> 3.5"},
{:logger_file_backend, "~> 0.0.13"},
{:telemetry_metrics, "~> 0.6"},
{:telemetry_metrics, "~> 1.0"},
{:telemetry_poller, "~> 1.0"},
{:plug_cowboy, "~> 2.5"},
{:prom_ex, "~> 1.8"},
{:emqtt, github: "emqx/emqtt", tag: "1.6.1", system_env: [{"BUILD_WITHOUT_QUIC", "1"}]},
{:prom_ex, "~> 1.11"},
{:emqtt, github: "emqx/emqtt", tag: "1.14.0", system_env: [{"BUILD_WITHOUT_QUIC", "1"}]},
{:ecto_psql_extras, "~> 0.7"},
{:yaml_elixir, "~> 2.9.0"},
{:yaml_elixir, "~> 2.11.0"},
{:cowlib, "~> 2.11.0", override: true},
# dev deps
{:mox, "~> 1.0", only: :test},
Expand Down
Loading
Loading