Open nikonikoniko opened 2 years ago
status$ = YoutubeDownloader.isAvailavble() -> Observable<boolean>
type ServiceStatus =
// service ready
{ status: 200, message: string } |
// no data to operate on
{ status: 418, message: "no data to operate on" }
// missing cfg
{ status: 401, message: "missig config" as const } |
// server offline
{ status: 500, message: "cannot reach server" }
const status$ = YoutubeDownloader.status() -> Observable<ServiceStatus>
const serviceStatus = {
// service ready
ok: { status: 200, message: "ok lets go" },
// no data to operate on
nodata: { status: 418, message: "no data to operate on" },
// missing cfg
noconfig: { status: 401, message: "missig config" },
// server offline
noserver: { status: 500, message: "cannot reach server" }
} as const;
type StatusType = keyof typeof serviceStatus;
type ServiceStatus = typeof serviceStatus[StatusType];
const status = (dataNodes: Types.Data.Data[], config: Types.Config.PartialConfig): Observable<ServiceStatus> => {
log.debug(`creating status observable`);
if (!config.youtube_downloader?.api_url) return of(serviceStatus.noconfig);
currently,
isAvailable
functions return anObservable<boolean>
. This is not helpful if we need to figure out why a service is not available.I suggest for it to return
Observable<[boolean, status]>
or[Observable<boolean>, Observable<status>]
where