From fd6502223cfe1493155524818e65b1eaecaef515 Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Thu, 28 Aug 2025 18:49:29 +0000 Subject: [PATCH] spindle: allowing configuring queue size and max job count Signed-off-by: oppiliappan --- nix/vm.nix | 2 ++ spindle/server.go | 3 ++- nix/modules/spindle.nix | 16 ++++++++++++++++ spindle/config/config.go | 2 ++ 4 file(s) changed, 22 insertion(s)(+), 1 deletion(s)(-) diff --git a/nix/vm.nix b/nix/vm.nix --- a/nix/vm.nix +++ b/nix/vm.nix @@ -89,6 +89,8 @@ hostname = "localhost:6555"; listenAddr = "0.0.0.0:6555"; dev = true; + queueSize = 100; + maxJobCount = 2; secrets = { provider = "sqlite"; }; diff --git a/spindle/server.go b/spindle/server.go --- a/spindle/server.go +++ b/spindle/server.go @@ -100,7 +100,8 @@ return err } - jq := queue.NewQueue(100, 5) + jq := queue.NewQueue(cfg.Server.QueueSize, cfg.Server.MaxJobCount) + logger.Info("initialized queue", "queueSize", cfg.Server.QueueSize, "numWorkers", cfg.Server.MaxJobCount) collections := []string{ tangled.SpindleMemberNSID, diff --git a/nix/modules/spindle.nix b/nix/modules/spindle.nix --- a/nix/modules/spindle.nix +++ b/nix/modules/spindle.nix @@ -55,6 +55,20 @@ description = "DID of owner (required)"; }; + maxJobCount = mkOption { + type = types.int; + default = 2; + example = 5; + description = "Maximum number of concurrent jobs to run"; + }; + + queueSize = mkOption { + type = types.int; + default = 100; + example = 100; + description = "Maximum number of jobs queue up"; + }; + secrets = { provider = mkOption { type = types.str; @@ -108,6 +122,8 @@ "SPINDLE_SERVER_JETSTREAM=${cfg.server.jetstreamEndpoint}" "SPINDLE_SERVER_DEV=${lib.boolToString cfg.server.dev}" "SPINDLE_SERVER_OWNER=${cfg.server.owner}" + "SPINDLE_SERVER_MAX_JOB_COUNT=${toString cfg.server.maxJobCount}" + "SPINDLE_SERVER_QUEUE_SIZE=${toString cfg.server.queueSize}" "SPINDLE_SERVER_SECRETS_PROVIDER=${cfg.server.secrets.provider}" "SPINDLE_SERVER_SECRETS_OPENBAO_PROXY_ADDR=${cfg.server.secrets.openbao.proxyAddr}" "SPINDLE_SERVER_SECRETS_OPENBAO_MOUNT=${cfg.server.secrets.openbao.mount}" diff --git a/spindle/config/config.go b/spindle/config/config.go --- a/spindle/config/config.go +++ b/spindle/config/config.go @@ -17,6 +17,8 @@ Owner string `env:"OWNER, required"` Secrets Secrets `env:",prefix=SECRETS_"` LogDir string `env:"LOG_DIR, default=/var/log/spindle"` + QueueSize int `env:"QUEUE_SIZE, default=100"` + MaxJobCount int `env:"MAX_JOB_COUNT, default=2"` // max number of jobs that run at a time } func (s Server) Did() syntax.DID { -- tangled.sh