1
0
Fork 0
mirror of https://github.com/benbusby/farside.git synced 2025-05-03 17:10:03 +00:00

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
<url>/<service>/<...>), the app would pick a random value from the list
returned by redis.get('<service>') 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.
This commit is contained in:
Ben Busby 2021-10-21 17:07:43 -06:00
parent be9606094c
commit cf8dfc5a85
No known key found for this signature in database
GPG key ID: 339B7B7EB5333D14
4 changed files with 82 additions and 0 deletions

21
update.exs Normal file
View file

@ -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")