Settings

RELE

Default: {} (Empty dictionary)

A dictionary mapping all Relé configuration settings to values defined in your Django project’s settings.py. Example:

RELE = {
    'GC_CREDENTIALS_PATH': 'rele/settings/dummy-credentials.json',
    'MIDDLEWARE': [
        'rele.contrib.LoggingMiddleware',
        'rele.contrib.DjangoDBMiddleware',
    ],
    'SUB_PREFIX': 'mysubprefix',
    'APP_NAME': 'myappname',
    'ENCODER_PATH': 'rest_framework.utils.encoders.JSONEncoder',
    'ACK_DEADLINE': 120,
    'PUBLISHER_TIMEOUT': 3.0,
    'FILTER_SUBS_BY': boolean_function,
    'DEFAULT_RETRY_POLICY': RetryPolicy(10, 50),
    'GC_STORAGE_REGION': 'europe-west1',
}

GC_PROJECT_ID

Optional

GCP project id to use. If this is not provided then it is inferred via either service account’s project id or quota project id if using Application Default Credentials (ADC)

GC_CREDENTIALS_PATH

Optional

Path to service account json file with access to PubSub

MIDDLEWARE

Optional

Default: ['rele.contrib.LoggingMiddleware']

List of the middleware modules that will be included in the project. The order of execution follows FIFO.

It is strongly recommended that for Django integration, you add:

[
    'rele.contrib.LoggingMiddleware',
    'rele.contrib.DjangoDBMiddleware',
]

The DjangoDBMiddleware will take care of opening and closing connections to the db before and after your callbacks are executed. If this is left out, it is highly probable that your database will run out of connections in your connection pool.

The LoggingMiddleware will take care of logging subscription information before and after the callback is executed. The subscription message is only logged when an exception was raised while processing it. If you would like to log this message in every case, you should create a middleware of your own.

SUB_PREFIX

Optional

A prefix to all your subs that can be declared globally.

For instance, if you have two projects listening to one topic, you may want to add a prefix so that there can be two distinct subscribers to that one topic.

APP_NAME

Optional

The application name.

This should be unique to all the services running in the application ecosystem. It is used by the LoggingMiddleware and Prometheus integration.

ENCODER_PATH

Optional

Default: rest_framework.utils.encoders.JSONEncoder

Encoder class path to use for serializing your Python data structure to a json object when publishing.

Note

The default encoder class is subject to change in an upcoming release. It is advised that you use this setting explicitly.

ACK_DEADLINE

Optional

Ack deadline for all subscribers in seconds.

See also

The Google Pub/Sub documentation which states that The subscriber has a configurable, limited amount of time – known as the ackDeadline – to acknowledge the outstanding message. Once the deadline passes, the message is no longer considered outstanding, and Cloud Pub/Sub will attempt to redeliver the message.

PUBLISHER_BLOCKING

Optional

Default: False

Wait synchronously for the publishing result

See Google PubSub documentation for more info

PUBLISHER_TIMEOUT

Optional

Default: 3.0 seconds

Timeout that the publishing result will wait on the future to publish successfully while blocking.

See Google PubSub documentation for more info

THREADS_PER_SUBSCRIPTION

Optional

Default: 2

Number of threads that will be consumed for each subscription. Default behavior of the Google Cloud PubSub library is to use 10 threads per subscription. We thought this was too much for a default setting and have taken the liberty of reducing the thread count to 2. If you would like to maintain the default Google PubSub library behavior, please set this value to 10.

FILTER_SUBS_BY

Optional

Boolean function that applies a global filter on all subscriptions. For more information, please see Filtering Messages section.

DEFAULT_RETRY_POLICY

Optional

A RetryPolicy object which must be instantiated with minimum_backoff and maximum_backoff, that specifies in seconds how Pub/Sub retries message delivery for all the subscriptions.

If not set, the default retry policy is applied, meaning a minimum backoff of 10 seconds and a maximum backoff of 60 seconds. This generally implies that messages will be retried as soon as possible for healthy subscribers. RetryPolicy will be triggered on NACKs or acknowledgement deadline exceeded events for a given message.

GC_STORAGE_REGION

Optional

Set the Google Cloud’s region for storing the messages. By default is europe-west1