Skip to content

Commit

Permalink
HTTP Client client configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
sleipnir committed Nov 6, 2023
1 parent 7f85dca commit 79c7642
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ run-proxy-local2:
ERL_ZFLAGS='-proto_dist inet_tls -ssl_dist_optfile rel/overlays/local-mtls.ssl.conf' cd spawn_proxy/proxy && mix deps.get && PROXY_DATABASE_TYPE=$(database) PROXY_HTTP_PORT=9003 SPAWN_STATESTORE_KEY=3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE= iex --name spawn_a2@test.default.svc -S mix

run-proxy-local-3:
cd spawn_proxy/proxy && mix deps.get && PROXY_CLUSTER_STRATEGY=epmd SPAWN_USE_INTERNAL_NATS=true SPAWN_PUBSUB_ADAPTER=nats PROXY_DATABASE_PORT=3307 PROXY_DATABASE_TYPE=mariadb PROXY_DATABASE_POOL_SIZE=30 PROXY_HTTP_PORT=9003 USER_FUNCTION_PORT=8091 SPAWN_STATESTORE_KEY=3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE= iex --name spawn_a3@127.0.0.1 -S mix
cd spawn_proxy/proxy && mix deps.get && SPAWN_PROXY_LOGGER_LEVEL=debug PROXY_CLUSTER_STRATEGY=epmd SPAWN_USE_INTERNAL_NATS=true SPAWN_PUBSUB_ADAPTER=nats PROXY_DATABASE_PORT=3307 PROXY_DATABASE_TYPE=mariadb PROXY_DATABASE_POOL_SIZE=30 PROXY_HTTP_PORT=9003 USER_FUNCTION_PORT=8091 SPAWN_STATESTORE_KEY=3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE= iex --name spawn_a3@127.0.0.1 -S mix

run-proxy-local-nodejs-test:
ERL_ZFLAGS='-proto_dist inet_tls -ssl_dist_optfile rel/overlays/local-mtls.ssl.conf' cd spawn_proxy/proxy && mix deps.get && PROXY_DATABASE_TYPE=$(database) PROXY_HTTP_PORT=9001 SPAWN_STATESTORE_KEY=3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE= PROXY_ACTOR_SYSTEM_NAME=SpawnSysTest SPAWN_SUPERVISORS_STATE_HANDOFF_CONTROLLER=persistent iex --name spawn_a1@test.default.svc -S mix
Expand All @@ -163,7 +163,7 @@ run-sdk-local2:
cd spawn_sdk/spawn_sdk_example && mix deps.get && PROXY_CLUSTER_STRATEGY=epmd SPAWN_USE_INTERNAL_NATS=true SPAWN_PUBSUB_ADAPTER=nats PROXY_DATABASE_TYPE=$(database) SPAWN_STATESTORE_KEY=3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE= iex --name spawn_a2@127.0.0.1 -S mix

run-sdk-local3:
cd spawn_sdk/spawn_sdk_example && mix deps.get && PROXY_CLUSTER_STRATEGY=epmd SPAWN_USE_INTERNAL_NATS=true SPAWN_PUBSUB_ADAPTER=nats PROXY_DATABASE_TYPE=$(database) SPAWN_STATESTORE_KEY=3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE= iex --name spawn_a3@127.0.0.1 -S mix
cd spawn_sdk/spawn_sdk_example && mix deps.get && PROXY_CLUSTER_STRATEGY=epmd SPAWN_USE_INTERNAL_NATS=true SPAWN_PUBSUB_ADAPTER=nats PROXY_DATABASE_TYPE=mariadb PROXY_DATABASE_PORT=3307 SPAWN_STATESTORE_KEY=3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE= iex --name spawn_a3@127.0.0.1 -S mix

run-sdk-local-with-mariadb:
cd spawn_sdk/spawn_sdk_example && mix deps.get && PROXY_CLUSTER_STRATEGY=epmd SPAWN_USE_INTERNAL_NATS=true SPAWN_PUBSUB_ADAPTER=nats PROXY_DATABASE_PORT=3307 PROXY_DATABASE_TYPE=mariadb SPAWN_STATESTORE_KEY=3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE= iex --name spawn_a3@127.0.0.1 -S mix
Expand Down
6 changes: 6 additions & 0 deletions config/runtime.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Config

if config_env() == :prod do
config :logger,
level: String.to_atom(System.get_env("SPAWN_PROXY_LOGGER_LEVEL", "debug"))
end
8 changes: 8 additions & 0 deletions lib/actors/config/vapor_config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ defmodule Actors.Config.Vapor do
default: 9001, map: &String.to_integer/1, required: false},
{:proxy_http_client_adapter, "PROXY_HTTP_CLIENT_ADAPTER",
default: "finch", required: false},
{:proxy_http_client_adapter_pool_schedulers,
"PROXY_HTTP_CLIENT_ADAPTER_POOL_SCHEDULERS",
default: 0, map: &String.to_integer/1, required: false},
{:proxy_http_client_adapter_pool_size, "PROXY_HTTP_CLIENT_ADAPTER_POOL_SIZE",
default: 30, map: &String.to_integer/1, required: false},
{:proxy_http_client_adapter_pool_max_idle_timeout,
"PROXY_HTTP_CLIENT_ADAPTER_POOL_MAX_IDLE_TIMEOUT",
default: 1_000, map: &String.to_integer/1, required: false},
{:deployment_mode, "PROXY_DEPLOYMENT_MODE", default: "sidecar", required: false},
{:node_host_interface, "NODE_IP", default: "0.0.0.0", required: false},
{:proxy_cluster_strategy, "PROXY_CLUSTER_STRATEGY", default: "gossip", required: false},
Expand Down
18 changes: 9 additions & 9 deletions lib/actors/supervisors/protocol_supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ defmodule Actors.Supervisors.ProtocolSupervisor do
use Supervisor
require Logger

alias Actors.Config.Vapor, as: Config

@default_finch_pool_count System.schedulers_online()
@default_finch_pool_max_idle_timeout 1_000
@default_finch_pool_size 10

def start_link(config) do
Supervisor.start_link(__MODULE__, config, name: __MODULE__)
Expand All @@ -22,7 +18,6 @@ defmodule Actors.Supervisors.ProtocolSupervisor do

@impl true
def init(config) do
_actors_config = Config.load(Actors)
Protobuf.load_extensions()

children = [
Expand All @@ -43,15 +38,20 @@ defmodule Actors.Supervisors.ProtocolSupervisor do
end
end

defp build_finch_http_client_adapter(_config) do
defp build_finch_http_client_adapter(config) do
pool_schedulers =
if config.proxy_http_client_adapter_pool_schedulers == 0,
do: @default_finch_pool_count,
else: config.proxy_http_client_adapter_pool_schedulers

{
Finch,
name: SpawnHTTPClient,
pools: %{
:default => [
size: @default_finch_pool_size,
count: @default_finch_pool_count,
pool_max_idle_time: @default_finch_pool_max_idle_timeout
count: pool_schedulers,
pool_max_idle_time: config.proxy_http_client_adapter_pool_max_idle_timeout,
size: config.proxy_http_client_adapter_pool_size
]
}
}
Expand Down
6 changes: 6 additions & 0 deletions spawn_operator/spawn_operator/lib/spawn_operator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ defmodule SpawnOperator do
Map.get(annotations, "spawn-eigr.io/cluster-poling-interval", "3000"),
proxy_mode: Map.get(annotations, "spawn-eigr.io/sidecar-mode", "sidecar"),
proxy_http_port: Map.get(annotations, "spawn-eigr.io/sidecar-http-port", "9001"),
proxy_http_client_adapter_pool_schedulers:
Map.get(annotations, "spawn-eigr.io/sidecar-http-pool-count", "8"),
proxy_http_client_adapter_pool_size:
Map.get(annotations, "spawn-eigr.io/sidecar-http-pool-size", "30"),
proxy_http_client_adapter_pool_max_idle_timeout:
Map.get(annotations, "spawn-eigr.io/sidecar-http-pool-max-idle-timeout", "1000"),
proxy_host_interface: Map.get(annotations, "spawn-eigr.io/sidecar-address", "0.0.0.0"),
proxy_image_tag:
Map.get(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ defmodule SpawnOperator.K8s.Proxy.CM.Configmap do
"data" => %{
"PROXY_APP_NAME" => name,
"PROXY_HTTP_PORT" => annotations.proxy_http_port,
"PROXY_HTTP_CLIENT_ADAPTER_POOL_SCHEDULERS" =>
annotations.proxy_http_client_adapter_pool_schedulers,
"PROXY_HTTP_CLIENT_ADAPTER_POOL_SIZE" => annotations.proxy_http_client_adapter_pool_size,
"PROXY_HTTP_CLIENT_ADAPTER_POOL_MAX_IDLE_TIMEOUT" =>
annotations.proxy_http_client_adapter_pool_max_idle_timeout,
"PROXY_DEPLOYMENT_MODE" => annotations.proxy_mode,
"PROXY_CLUSTER_POLLING" => annotations.cluster_poling_interval,
"PROXY_CLUSTER_STRATEGY" => "kubernetes-dns",
Expand Down
4 changes: 0 additions & 4 deletions spawn_proxy/proxy/config/runtime.exs

This file was deleted.

Loading

0 comments on commit 79c7642

Please sign in to comment.