mirror of
https://github.com/fastogt/fastocloud_admin.git
synced 2025-03-09 23:38:52 +00:00
Subscribers start impl
This commit is contained in:
parent
197173dd66
commit
2e5f60ab17
5 changed files with 38 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -38,6 +38,10 @@
|
|||
<br>
|
||||
{{ render_bootstrap_form(form.vods_host) }}
|
||||
<br>
|
||||
{{ render_bootstrap_form(form.subscribers_host) }}
|
||||
<br>
|
||||
{{ render_bootstrap_form(form.bandwidth_host) }}
|
||||
<br>
|
||||
{{ render_bootstrap_field(form.feedback_directory) }}
|
||||
<br>
|
||||
{{ render_bootstrap_field(form.timeshifts_directory) }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue