mirror of
https://github.com/benbusby/farside.git
synced 2025-06-08 10:26:36 +00:00
show fallback if there are no instances avail
This commit is contained in:
parent
9b7c544466
commit
e2ca414f79
3 changed files with 12 additions and 2 deletions
1
.envrc
1
.envrc
|
@ -1 +1,2 @@
|
||||||
export FARSIDE_PORT="4001"
|
export FARSIDE_PORT="4001"
|
||||||
|
export FARSIDE_TIMEOUT="10000"
|
2
app.json
2
app.json
|
@ -6,7 +6,7 @@
|
||||||
"keywords": ["elixir", "farside" ],
|
"keywords": ["elixir", "farside" ],
|
||||||
"env": {
|
"env": {
|
||||||
"MIX_ENV": "prod",
|
"MIX_ENV": "prod",
|
||||||
"FARSIDE_SERVICES_JSON": {
|
"FARSIDE_SERVICES_JSON_DATA": {
|
||||||
"description": "The base64(json) of services available (https://www.base64encode.org)",
|
"description": "The base64(json) of services available (https://www.base64encode.org)",
|
||||||
"value": "",
|
"value": "",
|
||||||
"required": false
|
"required": false
|
||||||
|
|
|
@ -39,6 +39,15 @@ defmodule Farside do
|
||||||
|> Enum.reduce(%{}, fn service, acc ->
|
|> Enum.reduce(%{}, fn service, acc ->
|
||||||
{_, data} = :ets.lookup(String.to_atom(service), :data) |> List.first()
|
{_, data} = :ets.lookup(String.to_atom(service), :data) |> List.first()
|
||||||
|
|
||||||
|
instances =
|
||||||
|
case Enum.count(data.instances) == 0 do
|
||||||
|
true ->
|
||||||
|
[data.fallback]
|
||||||
|
|
||||||
|
false ->
|
||||||
|
data.instances
|
||||||
|
end
|
||||||
|
|
||||||
Map.put(
|
Map.put(
|
||||||
acc,
|
acc,
|
||||||
String.replace_prefix(
|
String.replace_prefix(
|
||||||
|
@ -46,7 +55,7 @@ defmodule Farside do
|
||||||
@service_prefix,
|
@service_prefix,
|
||||||
""
|
""
|
||||||
),
|
),
|
||||||
data.instances
|
instances
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue