feat: build schedule events exclusively in playout (#2946)

### Description

Build and use the schedule events only in playout, the events generated
by legacy are not used anymore.

This ensure that we don't have to maintain 2 different implementation in
2 different languages. We still need the php function to run to make
sure the side effects of this function are executed (filling the
schedule in the DB).
This commit is contained in:
Jonas L 2024-04-27 20:09:16 +02:00 committed by GitHub
parent c02502ad9d
commit 40b4fc7f66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 14 additions and 18 deletions

View File

@ -197,8 +197,10 @@ class PreferenceController extends Zend_Controller_Action
if ($changeRGenabled || $changeRGmodifier) { if ($changeRGenabled || $changeRGmodifier) {
Application_Model_Preference::SetEnableReplayGain($values['enableReplayGain']); Application_Model_Preference::SetEnableReplayGain($values['enableReplayGain']);
Application_Model_Preference::setReplayGainModifier($values['replayGainModifier']); Application_Model_Preference::setReplayGainModifier($values['replayGainModifier']);
$md = ['schedule' => Application_Model_Schedule::getSchedule()]; // The side effects of this function are still required to fill the schedule, we
Application_Model_RabbitMq::SendMessageToPypo('update_schedule', $md); // don't use the returned schedule.
Application_Model_Schedule::getSchedule();
Application_Model_RabbitMq::SendMessageToPypo('update_schedule', []);
// Application_Model_RabbitMq::PushSchedule(); // Application_Model_RabbitMq::PushSchedule();
} }

View File

@ -5,8 +5,10 @@ class RabbitMqPlugin extends Zend_Controller_Plugin_Abstract
public function dispatchLoopShutdown() public function dispatchLoopShutdown()
{ {
if (Application_Model_RabbitMq::$doPush) { if (Application_Model_RabbitMq::$doPush) {
$md = ['schedule' => Application_Model_Schedule::getSchedule()]; // The side effects of this function are still required to fill the schedule, we
Application_Model_RabbitMq::SendMessageToPypo('update_schedule', $md); // don't use the returned schedule.
Application_Model_Schedule::getSchedule();
Application_Model_RabbitMq::SendMessageToPypo('update_schedule', []);
} }
if (memory_get_peak_usage() > 30 * 2 ** 20) { if (memory_get_peak_usage() > 30 * 2 ** 20) {

View File

@ -109,6 +109,8 @@ while ($showTime < $endDate) {
} }
if (Application_Model_RabbitMq::$doPush) { if (Application_Model_RabbitMq::$doPush) {
$md = ['schedule' => Application_Model_Schedule::getSchedule()]; // The side effects of this function are still required to fill the schedule, we
Application_Model_RabbitMq::SendMessageToPypo('update_schedule', $md); // don't use the returned schedule.
Application_Model_Schedule::getSchedule();
Application_Model_RabbitMq::SendMessageToPypo('update_schedule', []);
} }

View File

@ -17,7 +17,7 @@ from ..liquidsoap.client import LiquidsoapClient
from ..liquidsoap.models import Info, MessageFormatKind, StreamPreferences, StreamState from ..liquidsoap.models import Info, MessageFormatKind, StreamPreferences, StreamState
from .events import Events, FileEvent, FileEvents from .events import Events, FileEvent, FileEvents
from .liquidsoap import Liquidsoap from .liquidsoap import Liquidsoap
from .schedule import get_schedule, receive_schedule from .schedule import get_schedule
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -70,7 +70,7 @@ class PypoFetch(Thread):
logger.debug("handling event %s: %s", command, message) logger.debug("handling event %s: %s", command, message)
if command == "update_schedule": if command == "update_schedule":
self.schedule_data = receive_schedule(message["schedule"]["media"]) self.schedule_data = get_schedule(self.api_client)
self.process_schedule(self.schedule_data) self.process_schedule(self.schedule_data)
elif command == "reset_liquidsoap_bootstrap": elif command == "reset_liquidsoap_bootstrap":
self.set_bootstrap_variables() self.set_bootstrap_variables()

View File

@ -15,7 +15,6 @@ from .events import (
WebStreamEvent, WebStreamEvent,
datetime_to_event_key, datetime_to_event_key,
event_isoparse, event_isoparse,
parse_any_event,
) )
@ -213,12 +212,3 @@ def generate_webstream_events(
show_name=show["name"], show_name=show["name"],
) )
insert_event(events, schedule_end_event_key, stream_output_end_event) insert_event(events, schedule_end_event_key, stream_output_end_event)
def receive_schedule(schedule: Dict[str, dict]) -> Events:
events: Dict[str, AnyEvent] = {}
for event_key, event in schedule.items():
events[event_key] = parse_any_event(event)
return events