Commit 60923cf0 authored by Lukas Burgey's avatar Lukas Burgey Committed by lukas.burgey
Browse files

Make the broker interface more consistent

parent 9a387256
......@@ -18,6 +18,13 @@ def publish_to_user(user, obj):
dumps(serializers.UpdateSerializer(obj).data),
)
def publish_deployment_state(deployment_state):
from .serializers.clients import DeploymentStateSerializer
RabbitMQInstance.load().publish_deployment_state(
deployment_state,
dumps(DeploymentStateSerializer(deployment_state).data),
)
# singleton for simple configs
# https://steelkiwi.com/blog/practical-application-singleton-design-pattern/
......@@ -128,12 +135,11 @@ class RabbitMQInstance(SingletonModel):
self._init_exchanges(channel)
connection.close()
def publish_deployment_state(self, deployment_state):
from .serializers.clients import DeploymentStateSerializer
def publish_deployment_state(self, deployment_state, msg):
self._publish(
'services',
deployment_state.service.name,
dumps(DeploymentStateSerializer(deployment_state).data),
msg,
)
def publish_to_user(self, user, msg):
......
......@@ -11,7 +11,7 @@ from django_mysql.models import JSONField
from polymorphic.models import PolymorphicModel
from feudal.backend.models import Site, Service
from feudal.backend.models.brokers import publish_to_user, RabbitMQInstance
from feudal.backend.models.brokers import publish_to_user, publish_deployment_state
from feudal.backend.models.users import User, SSHPublicKey
from feudal.backend.models.auth.vos import VO
......@@ -618,7 +618,7 @@ class DeploymentState(models.Model):
if settings.DEBUG_PUBLISHING:
LOGGER.debug(self.msg('publish_to_client'))
RabbitMQInstance.load().publish_deployment_state(self)
publish_deployment_state(self)
def msg(self, msg):
return ' {} - {}'.format(self, msg)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment