Skip to content

Commit

Permalink
Add initial test for pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
zacksiri committed Oct 25, 2024
1 parent 41ce9ee commit e4a6145
Show file tree
Hide file tree
Showing 6 changed files with 492 additions and 3 deletions.
4 changes: 4 additions & 0 deletions config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ config :uplink, Uplink.Data, mode: "pro"

config :uplink, Uplink.Monitors, enabled: false

config :uplink, Uplink.Metrics.Pipeline,
producer_module: Broadway.DummyProducer,
producer_options: []

config :uplink, Uplink.Repo,
username:
System.get_env("UPLINK_DB_USERNAME") || System.get_env("POSTGRES_USERNAME"),
Expand Down
12 changes: 11 additions & 1 deletion lib/uplink/metrics/pipeline.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,21 @@ defmodule Uplink.Metrics.Pipeline do
require Logger

def start_link(_opts \\ []) do
configuration = Application.get_env(:uplink, __MODULE__) || []

producer_module =
Keyword.get(configuration, :producer_module, Uplink.Metrics.Producer)

producer_options =
Keyword.get(configuration, :producer_options,
poll_interval: :timer.seconds(15)
)

Broadway.start_link(__MODULE__,
name: __MODULE__,
context: :metrics,
producer: [
module: {Uplink.Metrics.Producer, [poll_interval: :timer.seconds(15)]},
module: {producer_module, producer_options},
concurrency: 1
],
processors: [
Expand Down
5 changes: 3 additions & 2 deletions lib/uplink/monitors.ex
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ defmodule Uplink.Monitors do
end

def config(key, default) do
Application.get_env(:uplink, __MODULE__)
|> Keyword.get(key, default)
configuration = Application.get_env(:uplink, __MODULE__) || []

Keyword.get(configuration, key, default)
end
end
Loading

0 comments on commit e4a6145

Please sign in to comment.