Skip to content

Commit

Permalink
Disable suspensions
Browse files Browse the repository at this point in the history
  • Loading branch information
slinkydeveloper committed Oct 31, 2023
1 parent 19c0979 commit 53dbb8c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/embedded/invocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export const doInvoke = async <I, O>(
const stateMachine = new StateMachine(
connection,
journal,
ProtocolMode.BIDI_STREAM
ProtocolMode.BIDI_STREAM,
-1
);

//
Expand Down
17 changes: 10 additions & 7 deletions src/state_machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,11 @@ export class StateMachine<I, O> implements RestateStreamConsumer {
// Suspension timeout that gets set and cleared based on completion messages;
private suspensionTimeout?: NodeJS.Timeout;

private readonly suspensionMillis = 30_000;

constructor(
private readonly connection: Connection,
private readonly invocation: Invocation<I, O>,
private readonly protocolMode: ProtocolMode
private readonly protocolMode: ProtocolMode,
private readonly suspensionMillis: number = 30_000
) {
this.localStateStore = invocation.localStateStore;

Expand Down Expand Up @@ -383,11 +382,15 @@ export class StateMachine<I, O> implements RestateStreamConsumer {
"Scheduling suspension in " + delay + " ms"
);

// Set a new suspension with a new timeout
// The suspension will only be sent if the timeout is not canceled due to a completion.
this.suspensionTimeout = setTimeout(() => {
if (delay == 0) {
this.suspend();
}, delay);
} else if (delay > 0) {
// Set a new suspension with a new timeout
// The suspension will only be sent if the timeout is not canceled due to a completion.
this.suspensionTimeout = setTimeout(() => {
this.suspend();
}, delay);
}
}

// Suspension timeouts:
Expand Down

0 comments on commit 53dbb8c

Please sign in to comment.