-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider minimum update period to refresh manifest (Simpler alternative) #347
Conversation
This looks pretty nice 👍 . I'm thinking about if we can write code even more concize by changing the place where we catch "needs-manifest-refresh" events, to perform all manifest updates in the same place. |
Oh yeah, also run |
ae943e4
to
35a1a0c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're quasi done! 👍
src/core/pipelines/manifest/index.ts
Outdated
return parser({ response: value, url }).pipe( | ||
map(({ manifest: parsedManifest }) => { | ||
const manifest = new Manifest(parsedManifest, warning$, transport.options); | ||
const manifestFetchingDuration = sentTime ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've two main problems with the fact that we communicate a manifestFetchingDuration
:
- it is not a fetching duration but a fetch + parse one
- the time between this operation and the usage of it could be extended in future evolutions without us expecting any problem with that
If I understood it correctly this operation should be the closest possible to performance.now
at the time the corresponding timeout is started.
Why not just communicating the requestTime
. It might even make more sense as a manifestUpdate
event, as it can be used to sort chronologically such updates.
src/core/stream/index.ts
Outdated
const loadStream = StreamLoader({ // Behold! | ||
mediaElement, | ||
manifest, | ||
manifestFetchingDuration, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not regrouping these two under a manifestInfos
name or something?
(With both the manifest and the requestTime)
src/core/stream/refresh_manifest.ts
Outdated
}), | ||
share() // share the previous side effect | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks clean 👍
src/core/stream/stream_loader.ts
Outdated
// the update period has elapsed. | ||
const updateManifest$ = refreshMinimumUpdatePeriod$.pipe( | ||
mergeMap((lastUpdatePeriod) => { | ||
return observableTimer(lastUpdatePeriod * 1000).pipe( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To think of it the performance.now() - requestTime
difference might even be calculated here... To see if that makes sense and if it is readable
src/core/stream/stream_loader.ts
Outdated
} | ||
return EMPTY; | ||
case "needs-manifest-refresh": | ||
log.debug("needs manifest to be refreshed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prepend now a Stream:
namespace in the StreamLoader's logs, to better help us debugging with logs on
src/core/stream/stream_loader.ts
Outdated
case "needs-manifest-refresh": | ||
log.debug("needs manifest to be refreshed"); | ||
// out-of-index messages require a complete reloading of the | ||
// manifest to refresh the current index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment makes no sense here (might me mine, but I just realized that)
src/core/stream/stream_loader.ts
Outdated
tap((manifestUpdateEvt: IManifestUpdateEvent) => { | ||
const { minimumUpdatePeriod } = manifestUpdateEvt.value.manifest; | ||
if (minimumUpdatePeriod && minimumUpdatePeriod > 0) { | ||
refreshMinimumUpdatePeriod$.next(minimumUpdatePeriod); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, didn't you forget to perform the substraction here?
src/core/stream/stream_loader.ts
Outdated
// Creates an observable which will refresh the manifest after | ||
// the update period has elapsed. | ||
const updateManifest$ = refreshMinimumUpdatePeriod$.pipe( | ||
mergeMap((lastUpdatePeriod) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a fan of this variable's name. It's actually the maximum refresh timeout of the manifest right here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, shouldn't it be a switchMap
?
cc4860a
to
8b0853e
Compare
Add a minimumUpdatePeriod field to Manifest, and use it in the StreamLoader to refresh the manifest at the given interval.
… manifest auto update
0f9152c
to
58508fe
Compare
No description provided.