mirror of
https://github.com/benbusby/farside.git
synced 2025-03-15 03:36:33 -04:00
Simplify retrieval of service keys from redis
Can just use a wildcard in the initial keys query, rather than grabbing all keys and filtering by service prefix.
This commit is contained in:
parent
85123cb524
commit
2189c9ddca
@ -2,16 +2,7 @@ defmodule Farside do
|
||||
@service_prefix Application.fetch_env!(:farside, :service_prefix)
|
||||
|
||||
def get_services_map do
|
||||
{:ok, redis_keys} = Redix.command(:redix, ["KEYS", "*"])
|
||||
|
||||
# Extract only service related keys
|
||||
service_list =
|
||||
Enum.filter(
|
||||
redis_keys,
|
||||
fn key ->
|
||||
String.starts_with?(key, @service_prefix)
|
||||
end
|
||||
)
|
||||
{:ok, service_list} = Redix.command(:redix, ["KEYS", "#{@service_prefix}*"])
|
||||
|
||||
# Match service name to list of available instances
|
||||
Enum.reduce(service_list, %{}, fn service, acc ->
|
||||
|
Loading…
x
Reference in New Issue
Block a user