feat: source timer
This commit is contained in:
parent
7c34e374ce
commit
8b65a3573c
@ -75,7 +75,7 @@ func Run(ctx context.Context, params RunParams) error {
|
|||||||
})
|
})
|
||||||
defer mp.Close()
|
defer mp.Close()
|
||||||
|
|
||||||
const uiUpdateInterval = 2 * time.Second
|
const uiUpdateInterval = time.Second
|
||||||
uiUpdateT := time.NewTicker(uiUpdateInterval)
|
uiUpdateT := time.NewTicker(uiUpdateInterval)
|
||||||
defer uiUpdateT.Stop()
|
defer uiUpdateT.Stop()
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ type BuildInfo struct {
|
|||||||
type Source struct {
|
type Source struct {
|
||||||
Container Container
|
Container Container
|
||||||
Live bool
|
Live bool
|
||||||
|
LiveChangedAt time.Time
|
||||||
Listeners int
|
Listeners int
|
||||||
Tracks []string
|
Tracks []string
|
||||||
RTMPURL string
|
RTMPURL string
|
||||||
|
@ -204,6 +204,7 @@ func (s *Actor) actorLoop(containerStateC <-chan domain.Container, errC <-chan e
|
|||||||
}
|
}
|
||||||
if ingressState.ready != s.state.Live || ingressState.listeners != s.state.Listeners {
|
if ingressState.ready != s.state.Live || ingressState.listeners != s.state.Listeners {
|
||||||
s.state.Live = ingressState.ready
|
s.state.Live = ingressState.ready
|
||||||
|
s.state.LiveChangedAt = time.Now()
|
||||||
s.state.Listeners = ingressState.listeners
|
s.state.Listeners = ingressState.listeners
|
||||||
resetFetchTracksT(time.Second)
|
resetFetchTracksT(time.Second)
|
||||||
sendState()
|
sendState()
|
||||||
|
@ -60,7 +60,9 @@ func TestIntegrationMediaServerStartStop(t *testing.T) {
|
|||||||
t,
|
t,
|
||||||
func() bool {
|
func() bool {
|
||||||
currState := mediaServer.State()
|
currState := mediaServer.State()
|
||||||
return currState.Live && currState.Container.HealthState == "healthy"
|
return currState.Live &&
|
||||||
|
!currState.LiveChangedAt.IsZero() &&
|
||||||
|
currState.Container.HealthState == "healthy"
|
||||||
},
|
},
|
||||||
time.Second*5,
|
time.Second*5,
|
||||||
time.Second,
|
time.Second,
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"git.netflux.io/rob/octoplex/domain"
|
"git.netflux.io/rob/octoplex/domain"
|
||||||
"github.com/gdamore/tcell/v2"
|
"github.com/gdamore/tcell/v2"
|
||||||
@ -319,7 +320,12 @@ func (ui *UI) redrawFromState(state domain.AppState) {
|
|||||||
ui.sourceViews.tracks.SetText(tracks)
|
ui.sourceViews.tracks.SetText(tracks)
|
||||||
|
|
||||||
if state.Source.Live {
|
if state.Source.Live {
|
||||||
ui.sourceViews.status.SetText("[black:green]receiving")
|
var durStr string
|
||||||
|
if !state.Source.LiveChangedAt.IsZero() {
|
||||||
|
durStr = fmt.Sprintf(" (%s)", time.Since(state.Source.LiveChangedAt).Round(time.Second))
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.sourceViews.status.SetText("[black:green]receiving" + durStr)
|
||||||
} else if state.Source.Container.State == "running" && state.Source.Container.HealthState == "healthy" {
|
} else if state.Source.Container.State == "running" && state.Source.Container.HealthState == "healthy" {
|
||||||
ui.sourceViews.status.SetText("[black:yellow]ready")
|
ui.sourceViews.status.SetText("[black:yellow]ready")
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user