Simple configuration of federation senders
This commit is contained in:
parent
0f94bdd77f
commit
db5bc1d93c
|
@ -55,96 +55,129 @@ in
|
||||||
default = lib.readFile ./matrix-synapse-log_config.yaml;
|
default = lib.readFile ./matrix-synapse-log_config.yaml;
|
||||||
};
|
};
|
||||||
|
|
||||||
workers = lib.mkOption {
|
workers = let
|
||||||
type = lib.types.attrsOf (lib.types.submodule ({config, ...}: {
|
inherit (lib.lists) any;
|
||||||
options.settings = lib.mkOption {
|
isReplication = l: any (r: any (n: n == "replication") r.names) l.resources;
|
||||||
type = lib.types.submodule {
|
|
||||||
freeformType = format.type;
|
|
||||||
|
|
||||||
options.worker_app = lib.mkOption {
|
dMRL = lib.lists.findFirst isReplication
|
||||||
type = lib.types.enum [
|
(throw "No replication listener configured!")
|
||||||
"synapse.app.generic_worker"
|
cfg.settings.listeners;
|
||||||
"synapse.app.pusher"
|
|
||||||
"synapse.app.appservice"
|
dMRH = lib.findFirst (x: true) (throw "Replication listener had no addresses")
|
||||||
"synapse.app.federation_sender"
|
dMRL.bind_addresses;
|
||||||
"synapse.app.media_repository"
|
dMRP = dMRL.port;
|
||||||
"synapse.app.user_dir"
|
in {
|
||||||
"synapse.app.frontend_proxy"
|
enable = lib.mkEnableOption "synapse worker support";
|
||||||
];
|
|
||||||
description = "The type of worker application";
|
mainReplicationHost = lib.mkOption {
|
||||||
};
|
type = lib.types.str;
|
||||||
options.worker_replication_host = lib.mkOption {
|
default = dMRH;
|
||||||
type = lib.types.str;
|
description = "Host of the main synapse instance's replication listener";
|
||||||
description = "The replication listeners ip on the main synapse process";
|
};
|
||||||
default = "127.0.0.1";
|
|
||||||
};
|
mainReplicationPort = lib.mkOption {
|
||||||
options.worker_replication_http_port = lib.mkOption {
|
type = lib.types.port;
|
||||||
type = lib.types.port;
|
default = dMRP;
|
||||||
description = "The replication listeners port on the main synapse process";
|
description = "Port for the main synapse instance's replication listener";
|
||||||
};
|
};
|
||||||
options.worker_listeners = lib.mkOption {
|
|
||||||
type = lib.types.listOf (lib.types.submodule {
|
federationSenders = lib.mkOption {
|
||||||
options.type = lib.mkOption {
|
type = lib.types.ints.positive;
|
||||||
type = lib.types.enum [ "http" "metrics" ];
|
description = "How many automatically configured federation senders to set up";
|
||||||
description = "The type of the listener";
|
default = 0;
|
||||||
default = "http";
|
};
|
||||||
};
|
|
||||||
options.port = lib.mkOption {
|
instances = lib.mkOption {
|
||||||
type = lib.types.port;
|
type = lib.types.attrsOf (lib.types.submodule ({config, ...}: {
|
||||||
description = "the TCP port to bind to";
|
options.settings = lib.mkOption {
|
||||||
};
|
type = lib.types.submodule {
|
||||||
options.bind_addresses = lib.mkOption {
|
freeformType = format.type;
|
||||||
type = lib.types.listOf lib.types.str;
|
|
||||||
description = "A list of local addresses to listen on";
|
options.worker_app = lib.mkOption {
|
||||||
};
|
type = lib.types.enum [
|
||||||
options.tls = lib.mkOption {
|
"synapse.app.generic_worker"
|
||||||
type = lib.types.bool;
|
"synapse.app.pusher"
|
||||||
description = "set to true to enable TLS for this listener. Will use the TLS key/cert specified in tls_private_key_path / tls_certificate_path.";
|
"synapse.app.appservice"
|
||||||
default = true;
|
"synapse.app.federation_sender"
|
||||||
};
|
"synapse.app.media_repository"
|
||||||
options.x_forwarded = lib.mkOption {
|
"synapse.app.user_dir"
|
||||||
type = lib.types.bool;
|
];
|
||||||
description = ''
|
description = "The type of worker application";
|
||||||
Only valid for an 'http' listener. Set to true to use the X-Forwarded-For header as the client IP.
|
};
|
||||||
Useful when Synapse is behind a reverse-proxy.
|
options.worker_replication_host = lib.mkOption {
|
||||||
'';
|
type = lib.types.str;
|
||||||
default = false;
|
default = cfg.workers.mainReplicationHost;
|
||||||
};
|
description = "The replication listeners ip on the main synapse process";
|
||||||
options.resources = lib.mkOption {
|
};
|
||||||
type = lib.types.listOf (lib.types.submodule {
|
options.worker_replication_http_port = lib.mkOption {
|
||||||
options.names = lib.mkOption {
|
type = lib.types.port;
|
||||||
type = lib.types.listOf (lib.types.enum [ "client" "consent" "federation" "keys" "media" "metrics" "openid" "replication" "static" "webclient" ]);
|
default = cfg.workers.mainReplicationPort;
|
||||||
description = "A list of resources to host on this port";
|
description = "The replication listeners port on the main synapse process";
|
||||||
};
|
};
|
||||||
options.compress = lib.mkOption {
|
options.worker_listeners = lib.mkOption {
|
||||||
type = lib.types.bool;
|
type = lib.types.listOf (lib.types.submodule {
|
||||||
description = "enable HTTP compression for this resource";
|
options.type = lib.mkOption {
|
||||||
default = false;
|
type = lib.types.enum [ "http" "metrics" ];
|
||||||
};
|
description = "The type of the listener";
|
||||||
});
|
default = "http";
|
||||||
};
|
};
|
||||||
});
|
options.port = lib.mkOption {
|
||||||
description = "Listener configuration for the worker, similar to the main synapse listener";
|
type = lib.types.port;
|
||||||
default = [];
|
description = "the TCP port to bind to";
|
||||||
|
};
|
||||||
|
options.bind_addresses = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
description = "A list of local addresses to listen on";
|
||||||
|
};
|
||||||
|
options.tls = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
description = "set to true to enable TLS for this listener. Will use the TLS key/cert specified in tls_private_key_path / tls_certificate_path.";
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
options.x_forwarded = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
description = ''
|
||||||
|
Only valid for an 'http' listener. Set to true to use the X-Forwarded-For header as the client IP.
|
||||||
|
Useful when Synapse is behind a reverse-proxy.
|
||||||
|
'';
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
options.resources = lib.mkOption {
|
||||||
|
type = lib.types.listOf (lib.types.submodule {
|
||||||
|
options.names = lib.mkOption {
|
||||||
|
type = lib.types.listOf (lib.types.enum [ "client" "consent" "federation" "keys" "media" "metrics" "openid" "replication" "static" "webclient" ]);
|
||||||
|
description = "A list of resources to host on this port";
|
||||||
|
};
|
||||||
|
options.compress = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
description = "enable HTTP compression for this resource";
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
});
|
||||||
|
description = "Listener configuration for the worker, similar to the main synapse listener";
|
||||||
|
default = [ ];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
}));
|
||||||
}));
|
default = { };
|
||||||
default = {};
|
description = "Worker configuration";
|
||||||
description = "Worker configuration";
|
example = {
|
||||||
example = {
|
"federation_sender1" = {
|
||||||
"federation_sender1" = {
|
settings = {
|
||||||
settings = {
|
worker_name = "federation_sender1";
|
||||||
worker_name = "federation_sender1";
|
worker_app = "synapse.app.federation_sender";
|
||||||
worker_app = "synapse.app.federation_sender";
|
|
||||||
|
|
||||||
worker_replication_host = "127.0.0.1";
|
worker_replication_host = "127.0.0.1";
|
||||||
worker_replication_http_port = 9093;
|
worker_replication_http_port = 9093;
|
||||||
worker_listeners = [ ];
|
worker_listeners = [ ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
settings = lib.mkOption {
|
settings = lib.mkOption {
|
||||||
type = lib.types.submodule {
|
type = lib.types.submodule {
|
||||||
|
@ -179,7 +212,7 @@ in
|
||||||
|
|
||||||
options.use_presence = lib.mkOption {
|
options.use_presence = lib.mkOption {
|
||||||
type = lib.types.bool;
|
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;
|
default = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -343,7 +376,7 @@ in
|
||||||
started, to ensure that all instances are running with the same config (otherwise
|
started, to ensure that all instances are running with the same config (otherwise
|
||||||
events may be dropped)
|
events may be dropped)
|
||||||
'';
|
'';
|
||||||
default = [];
|
default = [ ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -407,11 +440,16 @@ in
|
||||||
Restart = "on-failure";
|
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
|
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;
|
workerName = worker: worker.name;
|
||||||
workerSettings = worker: (worker.value.settings // {worker_name = (workerName worker);});
|
workerSettings = worker: (worker.value.settings // {worker_name = (workerName worker);});
|
||||||
workerConfig = worker: format.generate "matrix-synapse-worker-${workerName worker}-config.yaml" (workerSettings worker);
|
workerConfig = worker: format.generate "matrix-synapse-worker-${workerName worker}-config.yaml" (workerSettings worker);
|
||||||
|
|
Loading…
Reference in New Issue