Convert the Pulse Job configuration into a list of strings

This commit is contained in:
George Hickman 2018-08-17 13:42:48 +01:00 коммит произвёл George Hickman
Родитель 703c1dde62
Коммит 0c84435659
2 изменённых файлов: 33 добавлений и 46 удалений

Просмотреть файл

@ -112,34 +112,24 @@ push_sources = [
#### Jobs
Job Exchanges and Projects can be configured in the environment like so:
``PULSE_JOB_EXCHANGES`` defines a list of exchanges to listen to.
``PULSE_JOB_SOURCES`` defines a list of exchanges with projects.
```bash
export PULSE_JOB_EXCHANGES="exchange/taskcluster-treeherder/v1/jobs,exchange/fxtesteng/jobs"
export PULSE_JOB_SOURCES="exchange/taskcluster-treeherder/v1/jobs.mozilla-central:mozilla-inbound,exchange/fxtesteng/jobs.#",
```
``PULSE_JOB_PROJECTS`` defines a list of projects to listen to.
```bash
export PULSE_JOB_PROJECTS="try,mozilla-central"
```
In this example we've defined two exchanges:
The source settings are combined such that all `projects` are applied to **each** `exchange`.
The example settings above would produce the following settings:
* ``exchange/taskcluster-treeherder/v1/jobs``
* ``exchange/fxtesteng/jobs``
```python
[{
"exchange": "exchange/taskcluster-treeherder/v1/jobs",
"projects": [
"try",
"mozilla-central",
],
}, {
"exchange": "exchange/fxtesteng/jobs",
"projects": [
"try",
"mozilla-central",
],
}]
```
The taskcluster-treeherder exchange defines two projects:
* ``mozilla-central``
* ``mozilla-inbound``
The ``fxtesteng`` exchange defines a wildcard (``#``) for its project.
When Jobs are read from Pulse and added to Treeherder's celery queue we generate a routing key by prepending ``#.`` to each project key.
### Advanced Celery options

Просмотреть файл

@ -1,34 +1,31 @@
"""
Job and Push sources
Both source types define an exchange path followed by one or more routing key
parts. Routing keys are specified after a period (".") separated by colons
(":"). Routing keys use a colon separator to avoid problems with defining
multiple push sources in an environment variable which are comma separated.
"""
import environ
env = environ.Env()
exchanges = env.list("PULSE_JOB_EXCHANGES", default=[
"exchange/taskcluster-treeherder/v1/jobs",
# "exchange/fxtesteng/jobs",
# ... other CI systems
])
projects = env.list("PULSE_JOB_PROJECTS", default=[
"#",
# some specific repos TC can ingest from
# "mozilla-central.#",
# "mozilla-inbound.#",
])
# Specifies the Pulse exchanges Treeherder will ingest data from for Jobs. This
# list will be updated as new applications come online that Treeherder
# supports. Treeherder will subscribe with routing keys that are the project
# names. Wildcards such as ``#`` and ``*`` are supported for the project
# field.
job_sources = [{
"exchange": exchange,
"projects": projects,
} for exchange in exchanges]
# Specifies the Pulse exchanges Treeherder will ingest data from for Jobs.
# Projects specified after the period (".") delimiter and will be combined with
# the wildcard ("#") when used in prepare_consumer function when called by
# read_pulse_jobs.
job_sources = env.list(
"PULSE_JOB_SOURCES",
default=[
"exchange/taskcluster-treeherder/v1/jobs.#",
"exchange/fxtesteng/jobs.#",
# ... other CI systems
],
)
# Specifies the Pulse exchanges Treeherder will ingest data from for Push data.
# Routing keys are specified after a period ("."), separated by commas (",").
push_sources = [
"exchange/taskcluster-github/v1/push.#",
"exchange/taskcluster-github/v1/pull-request.#",