[Ingest Manager] Fix polling for new agent action (#77339)

This commit is contained in:
Nicolas Chaulet 2020-09-14 15:42:38 -04:00 committed by GitHub
parent 65b5f94a47
commit 0fb48950f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -53,11 +53,15 @@ function getInternalUserSOClient() {
}
function createNewActionsSharedObservable(): Observable<AgentAction[]> {
const internalSOClient = getInternalUserSOClient();
let lastTimestamp = new Date().toISOString();
return timer(0, AGENT_UPDATE_ACTIONS_INTERVAL_MS).pipe(
switchMap(() => {
return from(getNewActionsSince(internalSOClient, new Date().toISOString()));
const internalSOClient = getInternalUserSOClient();
const timestamp = lastTimestamp;
lastTimestamp = new Date().toISOString();
return from(getNewActionsSince(internalSOClient, timestamp));
}),
shareReplay({ refCount: true, bufferSize: 1 })
);