From cf8dfc5a85a7d655fef36ce735472a16635d8b7a Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Thu, 21 Oct 2021 17:07:43 -0600 Subject: Initialize update script My initial thought for this: create a simple redis db for storing key value pairs of instance -> list of live instances for each privacy front end (libreddit, bibliogram, etc). A script executed on a certain schedule would (in the background) check each instance to make sure it isn't down or unreasonably slow. If the instance is available, add it to a list of available instances in the db. When a user navigates to the revolver url (something like //<...>), the app would pick a random value from the list returned by redis.get('') and forward the user to that instance. As a side note, this could instead load the instances json from a remote source (like github or something) so that changes to instances don't need to involve a redeploy of the entire app. --- update.exs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 update.exs (limited to 'update.exs') diff --git a/update.exs b/update.exs new file mode 100644 index 0000000..6e42198 --- /dev/null +++ b/update.exs @@ -0,0 +1,21 @@ +defmodule Instance do + defstruct [ + instance_type: nil, + instance_list: [] + ] +end + +defmodule Instances do + def update(filename) do + {:ok, file} = File.read(filename) + {:ok, json} = Poison.decode(file, as: [%Instance{}]) + for x <- json do + IO.puts(x.instance_type) + for y <- x.instance_list do + IO.puts(" - " <> y) + end + end + end +end + +Instances.update("instances.json") -- cgit v1.2.3