Default: {} (Empty dictionary)

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

RELE = {
    'GC_CREDENTIALS_PATH': 'rele/settings/dummy-credentials.json',
    'SUB_PREFIX': 'mysubprefix',
    'APP_NAME': 'myappname',
    'ENCODER_PATH': 'rest_framework.utils.encoders.JSONEncoder',
    'ACK_DEADLINE': 120,
    'FILTER_SUBS_BY': boolean_function,
    'DEFAULT_RETRY_POLICY': RetryPolicy(10, 50),
    'GC_STORAGE_REGION': 'europe-west1',
    'CLIENT_OPTIONS': {'api_endpoint': ''}



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)



Path to service account json file with access to PubSub



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:


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.



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.



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.



Default: rest_framework.utils.encoders.JSONEncoder

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


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



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.



Default: False

Wait synchronously for the publishing result

See Google PubSub documentation for more info



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



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.



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



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.



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



Provide custom options for publisher and subscriber client. Following are three of the options.

  1. The api_endpoint property can be used to override the default endpoint provided by the client when transport is not explicitly provided.

  2. The client_cert_source property can be used to provide a client certificate for mTLS transport. If not provided, the default SSL client certificate will be used if present.

  3. The universe_domain property can be used to override the default “” universe. Note that the api_endpoint property still takes precedence; and universe_domain is currently not supported for mTLS.

For more information about the client options, please see Publisher Client and Subscriber Client.