Simple configuration of federation senders
This commit is contained in:
parent
0f94bdd77f
commit
db5bc1d93c
|
@ -55,7 +55,39 @@ in
|
|||
default = lib.readFile ./matrix-synapse-log_config.yaml;
|
||||
};
|
||||
|
||||
workers = lib.mkOption {
|
||||
workers = let
|
||||
inherit (lib.lists) any;
|
||||
isReplication = l: any (r: any (n: n == "replication") r.names) l.resources;
|
||||
|
||||
dMRL = lib.lists.findFirst isReplication
|
||||
(throw "No replication listener configured!")
|
||||
cfg.settings.listeners;
|
||||
|
||||
dMRH = lib.findFirst (x: true) (throw "Replication listener had no addresses")
|
||||
dMRL.bind_addresses;
|
||||
dMRP = dMRL.port;
|
||||
in {
|
||||
enable = lib.mkEnableOption "synapse worker support";
|
||||
|
||||
mainReplicationHost = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = dMRH;
|
||||
description = "Host of the main synapse instance's replication listener";
|
||||
};
|
||||
|
||||
mainReplicationPort = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
default = dMRP;
|
||||
description = "Port for the main synapse instance's replication listener";
|
||||
};
|
||||
|
||||
federationSenders = lib.mkOption {
|
||||
type = lib.types.ints.positive;
|
||||
description = "How many automatically configured federation senders to set up";
|
||||
default = 0;
|
||||
};
|
||||
|
||||
instances = lib.mkOption {
|
||||
type = lib.types.attrsOf (lib.types.submodule ({config, ...}: {
|
||||
options.settings = lib.mkOption {
|
||||
type = lib.types.submodule {
|
||||
|
@ -69,17 +101,17 @@ in
|
|||
"synapse.app.federation_sender"
|
||||
"synapse.app.media_repository"
|
||||
"synapse.app.user_dir"
|
||||
"synapse.app.frontend_proxy"
|
||||
];
|
||||
description = "The type of worker application";
|
||||
};
|
||||
options.worker_replication_host = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = cfg.workers.mainReplicationHost;
|
||||
description = "The replication listeners ip on the main synapse process";
|
||||
default = "127.0.0.1";
|
||||
};
|
||||
options.worker_replication_http_port = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
default = cfg.workers.mainReplicationPort;
|
||||
description = "The replication listeners port on the main synapse process";
|
||||
};
|
||||
options.worker_listeners = lib.mkOption {
|
||||
|
@ -125,12 +157,12 @@ in
|
|||
};
|
||||
});
|
||||
description = "Listener configuration for the worker, similar to the main synapse listener";
|
||||
default = [];
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}));
|
||||
default = {};
|
||||
default = { };
|
||||
description = "Worker configuration";
|
||||
example = {
|
||||
"federation_sender1" = {
|
||||
|
@ -145,6 +177,7 @@ in
|
|||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = lib.types.submodule {
|
||||
|
@ -179,7 +212,7 @@ in
|
|||
|
||||
options.use_presence = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
description = "disable presence tracking on this homeserver, if you're having perfomance issues this can have a big impact";
|
||||
description = "disable presence tracking, if you're having perfomance issues this can have a big impact";
|
||||
default = true;
|
||||
};
|
||||
|
||||
|
@ -343,7 +376,7 @@ in
|
|||
started, to ensure that all instances are running with the same config (otherwise
|
||||
events may be dropped)
|
||||
'';
|
||||
default = [];
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -407,11 +440,16 @@ in
|
|||
Restart = "on-failure";
|
||||
};
|
||||
};
|
||||
|
||||
services.matrix-synapse-next.settings.federation_sender_instances = lib.genList (x: "auto-fed-sender${toString x}") cfg.workers.federationSenders;
|
||||
services.matrix-synapse-next.workers.instances = lib.attrsets.genAttrs (lib.genList
|
||||
(x: "auto-fed-sender${toString x}") cfg.workers.federationSenders)
|
||||
(_: { settings.worker_app = "synapse.app.federation_sender";});
|
||||
})
|
||||
|
||||
({
|
||||
systemd.services = let
|
||||
workerList = lib.mapAttrsToList (name: value: lib.nameValuePair name value ) cfg.workers;
|
||||
workerList = lib.mapAttrsToList (name: value: lib.nameValuePair name value ) cfg.workers.instances;
|
||||
workerName = worker: worker.name;
|
||||
workerSettings = worker: (worker.value.settings // {worker_name = (workerName worker);});
|
||||
workerConfig = worker: format.generate "matrix-synapse-worker-${workerName worker}-config.yaml" (workerSettings worker);
|
||||
|
|
Loading…
Reference in New Issue