summary refs log tree commit diff
path: root/host/Rory-nginx/services/matrix/synapse/workers/client-reader.nix
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-08-16 14:39:37 +0200
committerRory& <root@rory.gay>2024-08-16 14:39:37 +0200
commit4a60627f7f5f4e6a64a93635bd0df2c7f6b2cd17 (patch)
tree8159e19ce6762e40f538a9a40f11b05eb4da7d09 /host/Rory-nginx/services/matrix/synapse/workers/client-reader.nix
parentUnify single workers (diff)
downloadRory-Open-Architecture-4a60627f7f5f4e6a64a93635bd0df2c7f6b2cd17.tar.xz
Start reworking other workers
Diffstat (limited to 'host/Rory-nginx/services/matrix/synapse/workers/client-reader.nix')
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/client-reader.nix103
1 files changed, 59 insertions, 44 deletions
diff --git a/host/Rory-nginx/services/matrix/synapse/workers/client-reader.nix b/host/Rory-nginx/services/matrix/synapse/workers/client-reader.nix
index 5f3acbc..937fabc 100644
--- a/host/Rory-nginx/services/matrix/synapse/workers/client-reader.nix
+++ b/host/Rory-nginx/services/matrix/synapse/workers/client-reader.nix
@@ -3,45 +3,47 @@
 let
   cfg = config.services.matrix-synapse;
   dbGroup = "small";
-  hasClientResource = false;
-  hasFederationResource = false;
   workers = lib.range 0 (cfg.clientReaders - 1);
   workerName = "client_reader";
-  routes =
-    [
-      "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/publicRooms$"
-      "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/joined_members$"
-      "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/context/.*$"
-      "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/members$"
-      "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/state$"
-      "~ ^/_matrix/client/v1/rooms/.*/hierarchy$"
-      "~ ^/_matrix/client/(v1|unstable)/rooms/.*/relations/"
-      "~ ^/_matrix/client/v1/rooms/.*/threads$"
-      "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/messages$"
-      "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/event"
-      "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/joined_rooms"
-      "~ ^/_matrix/client/(api/v1|r0|v3|unstable/.*)/rooms/.*/aliases"
-      "~ ^/_matrix/client/v1/rooms/.*/timestamp_to_event$"
-      "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/search"
-      "~ ^/_matrix/client/(r0|v3|unstable)/user/.*/filter(/|$)"
-      "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/directory/room/.*$"
-      "~ ^/_matrix/client/(r0|v3|unstable)/notifications$"
+  workerRoutes = {
+    client =
+      [
+        "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/publicRooms$"
+        "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/joined_members$"
+        "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/context/.*$"
+        "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/members$"
+        "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/state$"
+        "~ ^/_matrix/client/v1/rooms/.*/hierarchy$"
+        "~ ^/_matrix/client/(v1|unstable)/rooms/.*/relations/"
+        "~ ^/_matrix/client/v1/rooms/.*/threads$"
+        "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/messages$"
+        "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/event"
+        "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/joined_rooms"
+        "~ ^/_matrix/client/(api/v1|r0|v3|unstable/.*)/rooms/.*/aliases"
+        "~ ^/_matrix/client/v1/rooms/.*/timestamp_to_event$"
+        "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/search"
+        "~ ^/_matrix/client/(r0|v3|unstable)/user/.*/filter(/|$)"
+        "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/directory/room/.*$"
+        "~ ^/_matrix/client/(r0|v3|unstable)/notifications$"
 
-      # unstable
-      "~ ^/_matrix/client/unstable/im.nheko.summary/rooms/.*/summary$"
-    ]
-    ++ lib.optionals (cfg.authWorkers == 0) [
-      "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/login$"
-      "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/account/3pid$"
-      "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/account/whoami$"
-      "~ ^/_matrix/client/versions$"
-      "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/voip/turnServer$"
-      "~ ^/_matrix/client/(r0|v3|unstable)/register$"
-      "~ ^/_matrix/client/(r0|v3|unstable)/register/available$"
-      "~ ^/_matrix/client/(r0|v3|unstable)/auth/.*/fallback/web$"
-      "~ ^/_matrix/client/(r0|v3|unstable)/password_policy$"
-      "~ ^/_matrix/client/(r0|v3|unstable)/capabilities$"
-    ];
+        # unstable
+        "~ ^/_matrix/client/unstable/im.nheko.summary/rooms/.*/summary$"
+      ]
+      ++ lib.optionals (cfg.authWorkers == 0) [
+        "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/login$"
+        "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/account/3pid$"
+        "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/account/whoami$"
+        "~ ^/_matrix/client/versions$"
+        "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/voip/turnServer$"
+        "~ ^/_matrix/client/(r0|v3|unstable)/register$"
+        "~ ^/_matrix/client/(r0|v3|unstable)/register/available$"
+        "~ ^/_matrix/client/(r0|v3|unstable)/auth/.*/fallback/web$"
+        "~ ^/_matrix/client/(r0|v3|unstable)/password_policy$"
+        "~ ^/_matrix/client/(r0|v3|unstable)/capabilities$"
+      ];
+    federation = [ ];
+    media = [ ];
+  };
 in
 {
   config = lib.mkIf (cfg.clientReaders > 0) {
@@ -110,13 +112,26 @@ in
       );
     };
 
-    services.nginx.virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs (
-      lib.map (route: {
-        name = route;
-        value = {
-          proxyPass = "http://${workerName}";
-        };
-      }) routes
-    );
+    services.nginx = {
+      virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs (
+        lib.flatten (
+          lib.forEach
+            [
+              "client"
+              "federation"
+              "media"
+            ]
+            (
+              type:
+              lib.map (route: {
+                name = route;
+                value = {
+                  proxyPass = "http://unix:/run/matrix-synapse/${workerName}-${type}.sock";
+                };
+              }) workerRoutes.${type}
+            )
+        )
+      );
+    };
   };
 }