mirror of
https://github.com/ansible/awx.git
synced 2024-10-31 23:51:09 +03:00
Start of HA middleware.
This commit is contained in:
parent
57194c9a89
commit
0e623f2337
@ -23,3 +23,7 @@ class InstanceManager(models.Manager):
|
||||
if self.me().primary:
|
||||
return 'primary'
|
||||
return 'secondary'
|
||||
|
||||
def primary(self):
|
||||
"""Return the primary instance."""
|
||||
return self.get(primary=True)
|
||||
|
@ -61,3 +61,14 @@ class ActivityStreamMiddleware(threading.local):
|
||||
else:
|
||||
if instance.id not in self.instance_ids:
|
||||
self.instance_ids.append(instance.id)
|
||||
|
||||
|
||||
class HAMiddlware(object):
|
||||
"""A middleware class that checks to see whether the request is being
|
||||
served on a secondary instance, and redirects the request back to the
|
||||
primary instance if so.
|
||||
"""
|
||||
def process_request(self, request):
|
||||
"""Process the request, and redirect if this is a request on a
|
||||
secondary node.
|
||||
"""
|
||||
|
@ -116,6 +116,7 @@ TEMPLATE_CONTEXT_PROCESSORS += (
|
||||
)
|
||||
|
||||
MIDDLEWARE_CLASSES += (
|
||||
'awx.main.middleware.HAMiddleware',
|
||||
'awx.main.middleware.ActivityStreamMiddleware',
|
||||
'crum.CurrentRequestUserMiddleware',
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user