From 2e5f60ab17a263c82e8d0557828b87ff0a4da229 Mon Sep 17 00:00:00 2001 From: topilski Date: Mon, 10 Jun 2019 00:54:00 -0400 Subject: [PATCH] Subscribers start impl --- app/client/client.py | 5 +++-- app/service/forms.py | 4 ++++ app/service/server_entry.py | 8 ++++++++ app/service/service_client.py | 22 +++++++++++++++++++--- app/templates/service/base.html | 4 ++++ 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/app/client/client.py b/app/client/client.py index 6921531..9253790 100644 --- a/app/client/client.py +++ b/app/client/client.py @@ -44,6 +44,7 @@ class Client: VODS_IN_DIRECTORY = 'vods_in_directory' VODS_DIRECTORY = 'vods_directory' STREAMS = 'streams' + SUBSCRIBERS = 'subscribers' STREAM_ID = 'id' LICENSE_KEY = 'license_key' PATH = 'path' @@ -126,8 +127,8 @@ class Client: self._send_request(command_id, Commands.PREPARE_SERVICE_COMMAND, command_args) @is_active_decorator - def sync_service(self, command_id: int, streams: list): - command_args = {Client.STREAMS: streams} + def sync_service(self, command_id: int, streams: list, subscribers: list): + command_args = {Client.STREAMS: streams, Client.SUBSCRIBERS: subscribers} self._send_request(command_id, Commands.SYNC_SERVICE_COMMAND, command_args) @is_active_decorator diff --git a/app/service/forms.py b/app/service/forms.py index e2037d5..b201921 100644 --- a/app/service/forms.py +++ b/app/service/forms.py @@ -13,6 +13,8 @@ class ServiceSettingsForm(FlaskForm): host = FormField(HostAndPortForm, lazy_gettext(u'Host:'), validators=[]) http_host = FormField(HostAndPortForm, lazy_gettext(u'Http host:'), validators=[]) vods_host = FormField(HostAndPortForm, lazy_gettext(u'Vods host:'), validators=[]) + subscribers_host = FormField(HostAndPortForm, lazy_gettext(u'Subscribers host:'), validators=[]) + bandwidth_host = FormField(HostAndPortForm, lazy_gettext(u'Bandwidth host:'), validators=[]) feedback_directory = StringField(lazy_gettext(u'Feedback directory:'), validators=[InputRequired()]) timeshifts_directory = StringField(lazy_gettext(u'Timeshifts directory:'), validators=[InputRequired()]) @@ -32,6 +34,8 @@ class ServiceSettingsForm(FlaskForm): settings.host = self.host.get_data() settings.http_host = self.http_host.get_data() settings.vods_host = self.vods_host.get_data() + settings.subscribers_host = self.subscribers_host.get_data() + settings.bandwidth_host = self.bandwidth_host.get_data() settings.feedback_directory = self.feedback_directory.data settings.timeshifts_directory = self.timeshifts_directory.data diff --git a/app/service/server_entry.py b/app/service/server_entry.py index 7d7472b..0cd6a1e 100644 --- a/app/service/server_entry.py +++ b/app/service/server_entry.py @@ -24,6 +24,10 @@ class ServerSettings: DEFAULT_SERVICE_HTTP_PORT = 8000 DEFAULT_SERVICE_VODS_HOST = 'localhost' DEFAULT_SERVICE_VODS_PORT = 7000 + DEFAULT_SERVICE_SUBSCRIBERS_HOST = 'localhost' + DEFAULT_SERVICE_SUBSCRIBERS_PORT = 6000 + DEFAULT_SERVICE_BANDWIDTH_HOST = 'localhost' + DEFAULT_SERVICE_BANDWIDTH_PORT = 5000 name = StringField(unique=True, default=DEFAULT_SERVICE_NAME, max_length=MAX_SERVICE_NAME_LENGTH, min_length=MIN_SERVICE_NAME_LENGTH) @@ -32,6 +36,10 @@ class ServerSettings: port=DEFAULT_SERVICE_HTTP_PORT)) vods_host = EmbeddedDocumentField(HostAndPort, default=HostAndPort(host=DEFAULT_SERVICE_VODS_HOST, port=DEFAULT_SERVICE_VODS_PORT)) + subscribers_host = EmbeddedDocumentField(HostAndPort, default=HostAndPort(host=DEFAULT_SERVICE_SUBSCRIBERS_HOST, + port=DEFAULT_SERVICE_SUBSCRIBERS_PORT)) + bandwidth_host = EmbeddedDocumentField(HostAndPort, default=HostAndPort(host=DEFAULT_SERVICE_BANDWIDTH_HOST, + port=DEFAULT_SERVICE_BANDWIDTH_PORT)) feedback_directory = StringField(default=DEFAULT_FEEDBACK_DIR_PATH) timeshifts_directory = StringField(default=DEFAULT_TIMESHIFTS_DIR_PATH) diff --git a/app/service/service_client.py b/app/service/service_client.py index fff106e..61ffcbf 100644 --- a/app/service/service_client.py +++ b/app/service/service_client.py @@ -11,6 +11,8 @@ import app.constants as constants class ServiceClient(IClientHandler): HTTP_HOST = 'http_host' VODS_HOST = 'vods_host' + SUBSCRIBERS_HOST = 'subscribers_host' + BANDWIDTH_HOST = 'bandwidth_host' VERSION = 'version' @staticmethod @@ -74,7 +76,9 @@ class ServiceClient(IClientHandler): streams = [] for stream in self._service_settings.streams: streams.append(stream.config()) - return self._client.sync_service(self._gen_request_id(), streams) + + subscribers = [] + return self._client.sync_service(self._gen_request_id(), streams, subscribers) def get_http_host(self) -> str: return self._http_host @@ -82,6 +86,12 @@ class ServiceClient(IClientHandler): def get_vods_host(self) -> str: return self._vods_host + def get_subscribers_host(self) -> str: + return self._subscribers_host + + def get_bandwidth_host(self) -> str: + return self._bandwidth_host + def get_vods_in(self) -> list: return self._vods_in @@ -98,7 +108,9 @@ class ServiceClient(IClientHandler): self.sync_service() if self._handler: self._set_runtime_fields(resp.result[ServiceClient.HTTP_HOST], - resp.result[ServiceClient.VODS_HOST], resp.result[ServiceClient.VERSION]) + resp.result[ServiceClient.VODS_HOST], resp.result[ServiceClient.VODS_HOST], + resp.result[ServiceClient.SUBSCRIBERS_HOST], + resp.result[ServiceClient.BANDWIDTH_HOST]) self._handler.on_service_statistic_received(resp.result) if req.method == Commands.PREPARE_SERVICE_COMMAND and resp.is_message(): @@ -127,9 +139,13 @@ class ServiceClient(IClientHandler): self._handler.on_client_state_changed(status) # private - def _set_runtime_fields(self, http_host=None, vods_host=None, version=None, vods_in=None): + def _set_runtime_fields(self, http_host=None, vods_host=None, subscribers_host=None, bandwidth_host=None, + version=None, + vods_in=None): self._http_host = http_host self._vods_host = vods_host + self._subscribers_host = subscribers_host + self._bandwidth_host = bandwidth_host self._version = version self._vods_in = vods_in diff --git a/app/templates/service/base.html b/app/templates/service/base.html index 847cf58..5674563 100644 --- a/app/templates/service/base.html +++ b/app/templates/service/base.html @@ -38,6 +38,10 @@
{{ render_bootstrap_form(form.vods_host) }}
+ {{ render_bootstrap_form(form.subscribers_host) }} +
+ {{ render_bootstrap_form(form.bandwidth_host) }} +
{{ render_bootstrap_field(form.feedback_directory) }}
{{ render_bootstrap_field(form.timeshifts_directory) }}