add log streams

This commit is contained in:
M.Amin Rayej
2024-02-07 01:36:37 +03:30
parent ed81756265
commit ef68aa1e16
4 changed files with 858 additions and 59 deletions

View File

@@ -12,7 +12,7 @@ use crate::{
types::{
self, CreateNamespaceVars, DeployApp, DeployAppConnection, DeployAppVersion,
DeployAppVersionConnection, GetDeployAppAndVersion, GetDeployAppVersionsVars,
GetNamespaceAppsVars, Log, PackageVersionConnection, PublishDeployAppVars,
GetNamespaceAppsVars, Log, LogStream, PackageVersionConnection, PublishDeployAppVars,
},
GraphQLApiFailure, WasmerClient,
};
@@ -679,6 +679,7 @@ fn get_app_logs(
start: OffsetDateTime,
end: Option<OffsetDateTime>,
watch: bool,
streams: Option<Vec<LogStream>>,
) -> impl futures::Stream<Item = Result<Vec<Log>, anyhow::Error>> + '_ {
// Note: the backend will limit responses to a certain number of log
// messages, so we use try_unfold() to keep calling it until we stop getting
@@ -696,6 +697,7 @@ fn get_app_logs(
first: Some(10),
starting_from: unix_timestamp(start),
until: end.map(unix_timestamp),
streams: streams.clone(),
};
let fut = async move {
@@ -766,8 +768,9 @@ pub async fn get_app_logs_paginated(
start: OffsetDateTime,
end: Option<OffsetDateTime>,
watch: bool,
streams: Option<Vec<LogStream>>,
) -> impl futures::Stream<Item = Result<Vec<Log>, anyhow::Error>> + '_ {
let stream = get_app_logs(client, name, owner, tag, start, end, watch);
let stream = get_app_logs(client, name, owner, tag, start, end, watch, streams);
stream.map(|res| {
let mut logs = Vec::new();