init commit

This commit is contained in:
2026-04-16 14:20:58 -05:00
commit cc973cc11c
51 changed files with 2447 additions and 0 deletions

46
config/config.exs Normal file
View File

@@ -0,0 +1,46 @@
import Config
config :workload_service,
ecto_repos: [WorkloadService.Repo],
event_stores: [WorkloadService.EventStore]
config :workload_service, WorkloadServiceWeb.Endpoint,
url: [host: "localhost"],
adapter: Bandit.PhoenixAdapter,
render_errors: [
formats: [json: WorkloadServiceWeb.ErrorJSON],
layout: false
],
pubsub_server: WorkloadService.PubSub,
live_view: [signing_salt: "workload_secret"]
config :logger, :console,
format: "$time $metadata[$level] $message\n",
metadata: [:request_id]
config :phoenix, :json_library, Jason
config :workload_service, WorkloadService.CommandedApp,
event_store: [
adapter: Commanded.EventStore.Adapters.EventStore,
event_store: WorkloadService.EventStore
],
pub_sub: :local,
registry: :local
config :commanded,
event_store_adapter: Commanded.EventStore.Adapters.EventStore
config :commanded_ecto_projections,
repo: WorkloadService.Repo
config :flop, repo: WorkloadService.Repo
config :workload_service, WorkloadService.Repo,
database: "workload_service_dev",
username: "postgres",
password: "postgres",
host: "localhost",
pool_size: 10
import_config "#{config_env()}.exs"

42
config/dev.exs Normal file
View File

@@ -0,0 +1,42 @@
import Config
config :workload_service, :amqp_url, "amqp://guest:guest@localhost:5672"
config :workload_service, WorkloadService.EventStore,
serializer: Commanded.Serialization.JsonSerializer,
username: "postgres",
password: "postgres",
database: "workload_service_eventstore_dev",
hostname: "localhost",
pool_size: 10
config :workload_service, WorkloadService.Repo,
username: "postgres",
password: "postgres",
hostname: "localhost",
database: "workload_service_dev",
stacktrace: true,
show_sensitive_data_on_connection_error: true,
pool_size: 10
config :workload_service, WorkloadServiceWeb.Endpoint,
http: [ip: {127, 0, 0, 1}],
check_origin: false,
code_reloader: true,
debug_errors: true,
secret_key_base: "rSPVNB6DCC2RMMlmk9QkCVGAzasUD6AWh5ussctvNuUxgZL9DRnFXTo6jcIz6JpB",
watchers: []
config :workload_service, dev_routes: true
config :logger, :default_formatter, format: "[$level] $message\n"
config :phoenix, :stacktrace_depth, 20
config :phoenix, :plug_init_mode, :runtime
config :open_api_spex, :cache_adapter, OpenApiSpex.Plug.NoneCache
config :workload_service,
provider_service_url: "http://localhost:4002",
solicitation_service_url: "http://localhost:8081"

6
config/prod.exs Normal file
View File

@@ -0,0 +1,6 @@
import Config
config :logger, level: :debug
# Runtime production configuration, including reading
# of environment variables, is done on config/runtime.exs.

94
config/runtime.exs Normal file
View File

@@ -0,0 +1,94 @@
import Config
# config/runtime.exs is executed for all environments, including
# during releases. It is executed after compilation and before the
# system starts, so it is typically used to load production configuration
# and secrets from environment variables or elsewhere. Do not define
# any compile-time configuration in here, as it won't be applied.
# The block below contains prod specific runtime configuration.
logger_level =
case System.get_env("LOG_LEVEL", "info") do
"debug" -> :debug
"info" -> :info
"warn" -> :warning
"error" -> :error
val when val in ["warning", "error"] -> :error
_ -> :info
end
config :logger, level: logger_level
config :logger, :console, format: {Logger.Formatter, :format}
rabbitmq_host = System.get_env("RABBITMQ_HOST", "localhost")
rabbitmq_vhost = System.get_env("RABBITMQ_VHOST", "/")
rabbitmq_username = System.get_env("RABBITMQ_USERNAME")
rabbitmq_password = System.get_env("RABBITMQ_PASSWORD")
amqp_url =
if rabbitmq_username && rabbitmq_password do
"amqp://#{rabbitmq_username}:#{rabbitmq_password}@#{rabbitmq_host}/#{rabbitmq_vhost}"
end
if amqp_url do
config :workload_service, :amqp_url, amqp_url
end
# ## Using releases
#
# If you use `mix release`, you need to explicitly enable the server
# by passing the PHX_SERVER=true when you start it:
#
# PHX_SERVER=true bin/workload_service start
#
# Alternatively, you can use `mix phx.gen.release` to generate a `bin/server`
# script that automatically sets the env var above.
if System.get_env("PHX_SERVER") do
config :workload_service, WorkloadServiceWeb.Endpoint, server: true
end
if cookie = System.get_env("RELEASE_COOKIE") do
config :elixir, :cookie, cookie
end
if config_env() == :prod do
database_url =
System.get_env("DATABASE_URL") ||
raise """
environment variable DATABASE_URL is missing.
For example: ecto://USER:PASS@HOST/DATABASE
"""
maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: []
config :workload_service, WorkloadService.Repo,
url: database_url,
pool_size: String.to_integer(System.get_env("DATABASE_POOL_SIZE") || "1"),
socket_options: maybe_ipv6
config :workload_service, WorkloadService.EventStore,
serializer: Commanded.Serialization.JsonSerializer,
url: database_url,
schema: "eventstore",
pool_size: String.to_integer(System.get_env("EVENTSTORE_POOL_SIZE") || "1")
secret_key_base =
System.get_env("SECRET_KEY_BASE") ||
raise """
environment variable SECRET_KEY_BASE is missing.
You can generate one by calling: mix phx.gen.secret
"""
host = System.get_env("PHX_HOST") || "example.com"
config :workload_service, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
config :workload_service, WorkloadServiceWeb.Endpoint,
url: [host: host, port: String.to_integer(System.get_env("PORT", "4000")), scheme: "http"],
http: [
ip: {0, 0, 0, 0, 0, 0, 0, 0},
port: String.to_integer(System.get_env("PORT", "4000"))
],
secret_key_base: secret_key_base
end

24
config/test.exs Normal file
View File

@@ -0,0 +1,24 @@
import Config
config :workload_service, WorkloadService.Repo,
username: "postgres",
password: "postgres",
hostname: "localhost",
database: "workload_service_test#{System.get_env("MIX_TEST_PARTITION")}",
pool: Ecto.Adapters.SQL.Sandbox,
pool_size: System.schedulers_online() * 2
config :workload_service, WorkloadServiceWeb.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 4002],
secret_key_base: "workload_test_secret_key_base_at_least_64_bytes_long_for_testing",
server: false
config :logger, level: :warning
config :phoenix, :plug_init_mode, :runtime
config :workload_service, WorkloadService.Application,
event_store: [
adapter: Commanded.EventStore.Adapters.InMemory,
serializer: Commanded.Serialization.JsonSerializer
]