eventPersister workers
This commit is contained in:
parent
a2b4d2e341
commit
c7f34ff60b
|
@ -131,6 +131,12 @@ in
|
||||||
default = 0;
|
default = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
eventPersisters = lib.mkOption {
|
||||||
|
type = lib.types.ints.unsigned;
|
||||||
|
description = "How many automatically configured event-persisters to set up";
|
||||||
|
default = 0;
|
||||||
|
};
|
||||||
|
|
||||||
instances = lib.mkOption {
|
instances = lib.mkOption {
|
||||||
type = lib.types.attrsOf (lib.types.submodule ({config, ...}: {
|
type = lib.types.attrsOf (lib.types.submodule ({config, ...}: {
|
||||||
|
|
||||||
|
@ -159,14 +165,15 @@ in
|
||||||
|
|
||||||
options.worker_app = let
|
options.worker_app = let
|
||||||
mapTypeApp = t: {
|
mapTypeApp = t: {
|
||||||
"fed-sender" = "synapse.app.generic_worker";
|
"fed-sender" = "synapse.app.generic_worker";
|
||||||
"fed-receiver" = "synapse.app.generic_worker";
|
"fed-receiver" = "synapse.app.generic_worker";
|
||||||
"initial-sync" = "synapse.app.generic_worker";
|
"initial-sync" = "synapse.app.generic_worker";
|
||||||
"normal-sync" = "synapse.app.generic_worker";
|
"normal-sync" = "synapse.app.generic_worker";
|
||||||
|
"event-persist" = "synapse.app.generic_worker";
|
||||||
}.${t};
|
}.${t};
|
||||||
defaultApp = if (!isAuto)
|
defaultApp = if (!isAuto)
|
||||||
then "synapse.app.generic_worker"
|
then "synapse.app.generic_worker"
|
||||||
else mapTypeApp type;
|
else mapTypeApp type;
|
||||||
in lib.mkOption {
|
in lib.mkOption {
|
||||||
type = lib.types.enum [
|
type = lib.types.enum [
|
||||||
"synapse.app.generic_worker"
|
"synapse.app.generic_worker"
|
||||||
|
@ -218,10 +225,11 @@ in
|
||||||
};
|
};
|
||||||
options.resources = let
|
options.resources = let
|
||||||
typeToResources = t: {
|
typeToResources = t: {
|
||||||
"fed-receiver" = [ "federation" ];
|
"fed-receiver" = [ "federation" ];
|
||||||
"fed-sender" = [ ];
|
"fed-sender" = [ ];
|
||||||
"initial-sync" = [ "client" ];
|
"initial-sync" = [ "client" ];
|
||||||
"normal-sync" = [ "client" ];
|
"normal-sync" = [ "client" ];
|
||||||
|
"event-persist" = [ "replication" ];
|
||||||
}.${t};
|
}.${t};
|
||||||
in lib.mkOption {
|
in lib.mkOption {
|
||||||
type = lib.types.listOf (lib.types.submodule {
|
type = lib.types.listOf (lib.types.submodule {
|
||||||
|
@ -589,6 +597,33 @@ in
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
({
|
||||||
|
services.matrix-synapse-next.settings.instance_map = genAttrs' (lib.lists.range 1 cfg.workers.eventPersisters)
|
||||||
|
(i: "auto-event-persist${toString i}")
|
||||||
|
(i: let
|
||||||
|
isReplication = l: lib.lists.any (r: lib.lists.any (n: n == "replication") r.names) l.resources;
|
||||||
|
wRL = lib.lists.findFirst isReplication
|
||||||
|
(throw "No replication listener configured!")
|
||||||
|
cfg.workers.instances."auto-event-persist${toString i}".settings.listeners;
|
||||||
|
wRH = lib.findFirst (x: true) (throw "Replication listener had no addresses")
|
||||||
|
wRL.bind_addresses;
|
||||||
|
wRP = wRL.port;
|
||||||
|
in {
|
||||||
|
host = wRH;
|
||||||
|
port = wRP;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
services.matrix-synapse-next.settings.stream_writers.events = lib.genList (i: "auto-event-persist${toString (i + 1)}") cfg.workers.eventPersisters;
|
||||||
|
services.matrix-synapse-next.workers.instances = genAttrs' (lib.lists.range 1 cfg.workers.eventPersisters)
|
||||||
|
(i: "auto-event-persist${toString i}")
|
||||||
|
(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;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
})
|
||||||
])
|
])
|
||||||
|
|
||||||
({
|
({
|
||||||
|
|
Loading…
Reference in New Issue