summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Busby <noreply+git@benbusby.com>2021-10-21 17:07:43 -0600
committerBen Busby <noreply+git@benbusby.com>2021-10-21 17:07:43 -0600
commitcf8dfc5a85a7d655fef36ce735472a16635d8b7a (patch)
tree7433a9d7106afc9d91051d7c2b58cb02e27ef58e
parentbe9606094c256471e256b1d00d6b681528547d58 (diff)
downloadfarside-cf8dfc5a85a7d655fef36ce735472a16635d8b7a.tar.gz
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.
-rw-r--r--instances.json18
-rw-r--r--mix.exs30
-rw-r--r--mix.lock13
-rw-r--r--update.exs21
4 files changed, 82 insertions, 0 deletions
diff --git a/instances.json b/instances.json
new file mode 100644
index 0000000..9196b62
--- /dev/null
+++ b/instances.json
@@ -0,0 +1,18 @@
+[
+ {
+ "instance_type": "reddit",
+ "instance_test": "/r/popular",
+ "instance_list": [
+ "https://libredd.it",
+ "https://libreddit.spike.codes"
+ ]
+ },
+ {
+ "instance_type": "instagram",
+ "instance_test": "",
+ "instance_list": [
+ "https://bibliogram.art/u",
+ "https://bibliiogram.snopyta.org"
+ ]
+ }
+]
diff --git a/mix.exs b/mix.exs
new file mode 100644
index 0000000..0d0c8d0
--- /dev/null
+++ b/mix.exs
@@ -0,0 +1,30 @@
+defmodule RouterExample.MixProject do
+ use Mix.Project
+
+ def project do
+ [
+ app: :router_example,
+ version: "0.1.0",
+ elixir: "~> 1.8",
+ start_permanent: Mix.env() == :prod,
+ deps: deps()
+ ]
+ end
+
+ # Run "mix help compile.app" to learn about applications.
+ def application do
+ [
+ extra_applications: [:logger],
+ mod: {RouterExample.Application, []}
+ ]
+ end
+
+ # Run "mix help deps" to learn about dependencies.
+ defp deps do
+ [
+ {:jason, "~> 1.1"},
+ {:plug_cowboy, "~> 2.0"},
+ {:poison, "~> 5.0"}
+ ]
+ end
+end
diff --git a/mix.lock b/mix.lock
new file mode 100644
index 0000000..0e81d34
--- /dev/null
+++ b/mix.lock
@@ -0,0 +1,13 @@
+%{
+ "cowboy": {:hex, :cowboy, "2.9.0", "865dd8b6607e14cf03282e10e934023a1bd8be6f6bacf921a7e2a96d800cd452", [:make, :rebar3], [{:cowlib, "2.11.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "2c729f934b4e1aa149aff882f57c6372c15399a20d54f65c8d67bef583021bde"},
+ "cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"},
+ "cowlib": {:hex, :cowlib, "2.11.0", "0b9ff9c346629256c42ebe1eeb769a83c6cb771a6ee5960bd110ab0b9b872063", [:make, :rebar3], [], "hexpm", "2b3e9da0b21c4565751a6d4901c20d1b4cc25cbb7fd50d91d2ab6dd287bc86a9"},
+ "jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"},
+ "mime": {:hex, :mime, "2.0.1", "0de4c81303fe07806ebc2494d5321ce8fb4df106e34dd5f9d787b637ebadc256", [:mix], [], "hexpm", "7a86b920d2aedce5fb6280ac8261ac1a739ae6c1a1ad38f5eadf910063008942"},
+ "plug": {:hex, :plug, "1.12.1", "645678c800601d8d9f27ad1aebba1fdb9ce5b2623ddb961a074da0b96c35187d", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d57e799a777bc20494b784966dc5fbda91eb4a09f571f76545b72a634ce0d30b"},
+ "plug_cowboy": {:hex, :plug_cowboy, "2.5.2", "62894ccd601cf9597e2c23911ff12798a8a18d237e9739f58a6b04e4988899fe", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "ea6e87f774c8608d60c8d34022a7d073bd7680a0a013f049fc62bf35efea1044"},
+ "plug_crypto": {:hex, :plug_crypto, "1.2.2", "05654514ac717ff3a1843204b424477d9e60c143406aa94daf2274fdd280794d", [:mix], [], "hexpm", "87631c7ad914a5a445f0a3809f99b079113ae4ed4b867348dd9eec288cecb6db"},
+ "poison": {:hex, :poison, "5.0.0", "d2b54589ab4157bbb82ec2050757779bfed724463a544b6e20d79855a9e43b24", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "11dc6117c501b80c62a7594f941d043982a1bd05a1184280c0d9166eb4d8d3fc"},
+ "ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"},
+ "telemetry": {:hex, :telemetry, "1.0.0", "0f453a102cdf13d506b7c0ab158324c337c41f1cc7548f0bc0e130bbf0ae9452", [:rebar3], [], "hexpm", "73bc09fa59b4a0284efb4624335583c528e07ec9ae76aca96ea0673850aec57a"},
+}
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")