Skip to content

Commit

Permalink
PLTCONN-3034: Add keepAlive method to Response
Browse files Browse the repository at this point in the history
  • Loading branch information
bob-potter-sp committed Apr 27, 2023
1 parent 461e3f3 commit fe9a672
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/response/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Writable } from 'stream'
export interface Response<T> {
send(output: T): void
saveState(state: any): void
keepAlive(): void
}

/**
Expand Down Expand Up @@ -35,14 +36,26 @@ export class ResponseStream<T> implements Response<T> {
saveState(state: any): void {
this._writable.write(new RawResponse(state, ResponseType.State))
}

/**
* Indicates that the commands is still running.
*
* Can be used to avoid a timeout error in the case when a command
* is unable to return responses in a timely manner but is still
* actively processing the command.
*/
keepAlive(): void {
this._writable.write(new RawResponse({}, ResponseType.KeepAlive))
}
}

/**
* Enum representing different types of responses
*/
enum ResponseType {
Output = 'output',
State = 'state'
State = 'state',
KeepAlive = 'keepAlive'
}

/**
Expand Down

0 comments on commit fe9a672

Please sign in to comment.