From 119c40177ed8dcbcf3d87c87c0eda54179ee7f51 Mon Sep 17 00:00:00 2001 From: David Trattnig <david.trattnig@o94.at> Date: Fri, 23 Oct 2020 14:58:18 +0200 Subject: [PATCH] Ability to resolve channel type. #44 --- modules/core/channels.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/modules/core/channels.py b/modules/core/channels.py index 23b299be..c7976a91 100644 --- a/modules/core/channels.py +++ b/modules/core/channels.py @@ -131,6 +131,7 @@ class ChannelRouter(): Args: config (AuraConfig): The configuration + logger (Logger): The logger """ self.config = config self.logger = logger @@ -167,6 +168,24 @@ class ChannelRouter(): return self.active_channels[channel_type] + def type_of_channel(self, channel): + """ + Retrieves a `ChannelType` for the given `Channel`. + """ + if channel in ChannelType.QUEUE.channels: + return ChannelType.QUEUE + elif channel in ChannelType.FALLBACK_QUEUE.channels: + return ChannelType.FALLBACK_QUEUE + elif channel in ChannelType.HTTP.channels: + return ChannelType.HTTP + elif channel in ChannelType.HTTPS.channels: + return ChannelType.HTTPS + elif channel in ChannelType.LIVE.channels: + return ChannelType.LIVE + else: + return None + + def type_for_resource(self, resource_type): """ Retrieves a `ChannelType` for the given `ResourceType`. -- GitLab