Skip to content

Add CommonService.subscribe, with overridable queue names - #211

Closed
ndevenish wants to merge 1 commit into
DiamondLightSource:mainfrom
ndevenish:queue-subscribe
Closed

ndevenish wants to merge 1 commit into
DiamondLightSource:mainfrom
ndevenish:queue-subscribe

Conversation

@ndevenish

Copy link
Copy Markdown
Contributor

So far overridable queue names have only existed on a subset of manually implemented dlstbx services e.g. dlstbx.services.per_image_analysis.

This centralises all of what was previously

workflows.recipe.wrap_subscribe(
            self._transport,
            "strategy",
            self.generate_strategy,
            acknowledgement=True,
            log_extender=self.extend_log,
        )

to

self.subscribe("strategy", self._generate_strategy)

with defaults set to match the common settings (Everything can still be overridden).

This also implements a universal mechanism for overriding the queue - ServiceStarter (used by zocalo.go and dlstbx.go) now adds it's own --queue argument (unless the caller already has their own). If this is set, or if the service "environment" dictionary has a queue/queues entry, or if the WORKFLOWS_QUEUE environment variable is set, then it will replace the defaults subscribed queue under the following rules:

  • queuename=newname will replace the queue name if it matches exactly. Multiple entries can be space- or comma- separated.
  • newname will replace the queue name only if the service subscribes to one (non-broadcast) queue - if a second queue is connected then an error will be raised.
  • -q/--queue [NAME=]QUEUE can be passed multiple times to any frontend using ServiceStarter.

Services can call self.subscribe to subscribe to a queue of recipe
messages, with acknowledgement and recipe ID log extension enabled by
default. The queue name can be overridden from the service's
environment dictionary, which the service starter fills from a new
--queue [NAME=]QUEUE option and the WORKFLOWS_QUEUE environment
variable. Command line options take precedence over the variable.

The option is only added if the starter's subclass has not already
defined -q or --queue, so existing subclasses keep working.
@ndevenish ndevenish closed this Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant