enterprise.heartbeat package

Submodules

enterprise.heartbeat.checks module

Perform health checks om the services enterprise is dependant on.

enterprise.heartbeat.checks.check_discovery()

Check if course discovery service is up and running and accessible via API.

Raises

(DiscoveryNotAvailable) – raised if LMS service is not accessible for some reason.

Returns

A tuple containing service name and a message.

Return type

(str, str)

enterprise.heartbeat.checks.check_ecommerce()

Check if E-Commerce service is up and running and accessible via API.

Raises

(EcommerceNotAvailable) – raised if LMS service is not accessible for some reason.

Returns

A tuple containing service name and a message.

Return type

(str, str)

enterprise.heartbeat.checks.check_enterprise_catalog()

Check if enterprise catalog service is up and running and accessible via API.

Raises

(EnterpriseCatalogNotAvailable) – raised if LMS service is not accessible for some reason.

Returns

A tuple containing service name and a message.

Return type

(str, str)

enterprise.heartbeat.checks.check_lms()

Check if LMS service is up and running and accessible via API.

Raises

(LMSNotAvailable) – raised if LMS service is not accessible for some reason.

Returns

A tuple containing service name and a message.

Return type

(str, str)

enterprise.heartbeat.exceptions module

Exceptions for use by enterprise heartbeat module.

exception enterprise.heartbeat.exceptions.DiscoveryNotAvailable(message, *args)

Bases: enterprise.heartbeat.exceptions.ServiceNotAvailable

Raised when Course Discovery service is not available.

service_name = 'Course Discovery'
exception enterprise.heartbeat.exceptions.EcommerceNotAvailable(message, *args)

Bases: enterprise.heartbeat.exceptions.ServiceNotAvailable

Raised when E-Commerce service is not available.

service_name = 'E-Commerce'
exception enterprise.heartbeat.exceptions.EnterpriseCatalogNotAvailable(message, *args)

Bases: enterprise.heartbeat.exceptions.ServiceNotAvailable

Raised when Enterprise Catalog service is not available.

service_name = 'Enterprise Catalog'
exception enterprise.heartbeat.exceptions.LMSNotAvailable(message, *args)

Bases: enterprise.heartbeat.exceptions.ServiceNotAvailable

Raised when Learning Management System (LMS) service is not available.

service_name = 'Learning Management System (LMS)'
exception enterprise.heartbeat.exceptions.ServiceNotAvailable(message, service_name, *args)

Bases: Exception

All heartbeat service status exception inherit from this excepton.

message = ''
service_name = ''

enterprise.heartbeat.throttles module

Throttles for heartbeat API endpoints.

class enterprise.heartbeat.throttles.HeartbeatRateThrottle

Bases: rest_framework.throttling.UserRateThrottle

Throttle class for streamlining heartbeat traffic to manage server load.

rate = '60/min'
scope = 'heartbeat'

enterprise.heartbeat.utils module

Run health checks on all the services enterprise service is dependant on.

class enterprise.heartbeat.utils.Status

Bases: object

Status constants for service health check.

OK = 'OK'
UNAVAILABLE = 'UNAVAILABLE'
enterprise.heartbeat.utils.run_checks()

Run health checks on all the services and return the status of each service.

Returns

first boolean un the tuple tells of all services are up and running or not,

Dictionary containing the following key value pairs status: ‘OK’ if all the services are up

Return type

(bool, dict)

enterprise.heartbeat.views module

Views for enterprise heartbeat check.

enterprise.heartbeat.views.heartbeat(self, request, *args, **kwargs)

Simple view that an external service can use to check if the app is up.

Returns

A json doc of service id: status or message. If the status for any service is anything other than True,it returns HTTP code 503 (Service Unavailable); otherwise, it returns 200.

Return type

(JsonResponse)

Module contents

Enterprise heartbeat related code.