user-dir updater worker
This commit is contained in:
parent
bb105192c2
commit
43dbc17526
|
@ -137,6 +137,8 @@ in
|
|||
default = 0;
|
||||
};
|
||||
|
||||
useUserDirectoryWorker = lib.mkEnableOption "user directory worker";
|
||||
|
||||
instances = lib.mkOption {
|
||||
type = lib.types.attrsOf (lib.types.submodule ({config, ...}: {
|
||||
|
||||
|
@ -170,6 +172,7 @@ in
|
|||
"initial-sync" = "synapse.app.generic_worker";
|
||||
"normal-sync" = "synapse.app.generic_worker";
|
||||
"event-persist" = "synapse.app.generic_worker";
|
||||
"user-dir" = "synapse.app.generic_worker";
|
||||
}.${t};
|
||||
defaultApp = if (!isAuto)
|
||||
then "synapse.app.generic_worker"
|
||||
|
@ -230,6 +233,7 @@ in
|
|||
"initial-sync" = [ "client" ];
|
||||
"normal-sync" = [ "client" ];
|
||||
"event-persist" = [ "replication" ];
|
||||
"user-dir" = [ "client" ];
|
||||
}.${t};
|
||||
in lib.mkOption {
|
||||
type = lib.types.listOf (lib.types.submodule {
|
||||
|
@ -620,11 +624,22 @@ in
|
|||
(i: {
|
||||
isAuto = true; type = "event-persist"; index = i;
|
||||
settings.worker_listeners = [{ port = cfg.workers.workerStartingPort + cfg.workers.federationReceivers + cfg.workers.initialSyncers + cfg.workers.normalSyncers + i - 1;}]
|
||||
++ lib.optional wcfg.enableMetrics { port = cfg.workers.metricsStartingPort + cfg.workers.federationSenders + cfg.workers.federationReceivers + cfg.workers.initialSyncers + cfg.workers.normalSyncers + i;
|
||||
resources = [ { names = [ "metrics" ]; } ];
|
||||
++ lib.optional wcfg.enableMetrics { port = cfg.workers.metricsStartingPort + cfg.workers.federationSenders + cfg.workers.federationReceivers + cfg.workers.initialSyncers + cfg.workers.normalSyncers + i;
|
||||
resources = [ { names = [ "metrics" ]; } ];
|
||||
};
|
||||
});
|
||||
})
|
||||
|
||||
(lib.mkIf cfg.workers.useUserDirectoryWorker {
|
||||
services.matrix-synapse-next.workers.instances."auto-user-dir" = {
|
||||
isAuto = true; type = "user-dir"; index = 1;
|
||||
settings.worker_listeners = [{ port = cfg.workers.workerStartingPort + cfg.workers.federationReceivers + cfg.workers.initialSyncers + cfg.workers.normalSyncers + cfg.workers.eventPersisters + 1 - 1;}]
|
||||
++ lib.optional wcfg.enableMetrics { port = cfg.workers.metricsStartingPort + cfg.workers.federationSenders + cfg.workers.federationReceivers + cfg.workers.initialSyncers + cfg.workers.normalSyncers + cfg.workers.eventPersisters + 1;
|
||||
resources = [ { names = [ "metrics"]; } ];
|
||||
};
|
||||
};
|
||||
services.matrix-synapse-next.settings.update_user_directory_from_worker = "auto-user-dir";
|
||||
})
|
||||
])
|
||||
|
||||
({
|
||||
|
|
|
@ -103,7 +103,7 @@ in
|
|||
~^/_matrix/client/(api/v1|r0|v3|unstable)/presence/ synapse_client_presence;
|
||||
|
||||
# User directory search requests;
|
||||
~^/_matrix/client/(r0|v3|unstable)/user_directory/search$ synapse_client_search;
|
||||
~^/_matrix/client/(r0|v3|unstable)/user_directory/search$ synapse_client_user-dir;
|
||||
}
|
||||
|
||||
#Plugboard for url -> workers
|
||||
|
@ -115,6 +115,8 @@ in
|
|||
|
||||
synapse_federation synapse_worker_federation;
|
||||
synapse_federation_transaction synapse_worker_federation;
|
||||
|
||||
synapse_client_user-dir synapse_worker_user-dir;
|
||||
}
|
||||
|
||||
# from https://github.com/tswfi/synapse/commit/b3704b936663cc692241e978dce4ac623276b1a6
|
||||
|
@ -166,7 +168,7 @@ in
|
|||
socketAddresses = generateSocketAddresses "client" initialSyncers;
|
||||
in if initialSyncers != [ ] then
|
||||
lib.genAttrs socketAddresses (_: { })
|
||||
else config.services.nginx.upstreams.synapse_master.server;
|
||||
else config.services.nginx.upstreams.synapse_master.servers;
|
||||
extraConfig = ''
|
||||
hash $mxid_localpart consistent;
|
||||
'';
|
||||
|
@ -179,13 +181,21 @@ in
|
|||
socketAddresses = generateSocketAddresses "client" normalSyncers;
|
||||
in if normalSyncers != [ ] then
|
||||
lib.genAttrs socketAddresses (_: { })
|
||||
else config.services.nginx.upstreams.synapse_master.server;
|
||||
else config.services.nginx.upstreams.synapse_master.servers;
|
||||
extraConfig = ''
|
||||
hash $mxid_localpart consistent;
|
||||
'';
|
||||
};
|
||||
|
||||
|
||||
services.nginx.upstreams.synapse_worker_user-dir = {
|
||||
servers = let
|
||||
workers = getWorkersOfType "user-dir";
|
||||
socketAddresses = generateSocketAddresses "client" workers;
|
||||
in if workers != [ ] then
|
||||
lib.genAttrs socketAddresses (_: { })
|
||||
else config.services.nginx.upstreams.synapse_master.servers;
|
||||
};
|
||||
|
||||
services.nginx.virtualHosts."${cfg.public_baseurl}" = {
|
||||
enableACME = true;
|
||||
|
|
Loading…
Reference in New Issue