Skip to content

Commit

Permalink
Add wasInterrupted flag to Pending
Browse files Browse the repository at this point in the history
Reduce `PendingInterrupted` to a flag in `Pending`
  • Loading branch information
hubertp committed Dec 19, 2024
1 parent 1e49569 commit 9cf67eb
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 24 deletions.
13 changes: 3 additions & 10 deletions docs/language-server/protocol-language-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,7 @@ interface ExpressionUpdate {
An information about the computed value.

```typescript
type ExpressionUpdatePayload =
| Value
| DataflowError
| Panic
| Pending
| PendingInterrupted;
type ExpressionUpdatePayload = Value | DataflowError | Panic | Pending;

/** Indicates that the expression was computed to a value. */
interface Value {
Expand Down Expand Up @@ -429,12 +424,10 @@ interface Pending {
/** Optional amount of already done work as a number between `0.0` to `1.0`.
*/
progress?: number;
/** Indicates whether the computation of the expression has been interrupted and will be retried. */
wasInterrupted: boolean;
}

/** Indicates that the computation of the expression has been interrupted
* and will retried */
interface PendingInterrupted {}

/** Information about warnings associated with the value. */
interface Warnings {
/** The number of attached warnings. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,8 @@ final class ContextEventsListener(
functionSchema.map(toProtocolFunctionSchema)
)

case Api.ExpressionUpdate.Payload.Pending(m, p) =>
ContextRegistryProtocol.ExpressionUpdate.Payload.Pending(m, p)

case Api.ExpressionUpdate.Payload.PendingInterrupted =>
ContextRegistryProtocol.ExpressionUpdate.Payload.PendingInterrupted
case Api.ExpressionUpdate.Payload.Pending(m, p, i) =>
ContextRegistryProtocol.ExpressionUpdate.Payload.Pending(m, p, i)

case Api.ExpressionUpdate.Payload.DataflowError(trace) =>
ContextRegistryProtocol.ExpressionUpdate.Payload.DataflowError(trace)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ object ContextRegistryProtocol {

/** Indicates that an expression is pending a computation
*/
case class Pending(message: Option[String], progress: Option[Double])
case class Pending(message: Option[String], progress: Option[Double], wasInterrupted: Boolean)
extends Payload

/** Indicates that an expression's computation has been interrupted and shall be retried.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,9 @@ object Runtime {
/** Indicates that an expression is pending a computation
*/
@named("expressionUpdatePayloadPending")
case class Pending(message: Option[String], progress: Option[Double])
case class Pending(message: Option[String], progress: Option[Double], wasInterrupted: Boolean = false)
extends Payload

/** Indicates that an expression's computation has been interrupted and shall be retried.
*/
@named("expressionUpdatePayloadPendingInterrupted")
case object PendingInterrupted extends Payload

/** Indicates that the expression was computed to an error.
*
* @param trace the list of expressions leading to the root error.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ object ProgramExecutionSupport {
expressionId
))
) {
val payload = Api.ExpressionUpdate.Payload.PendingInterrupted
val payload = Api.ExpressionUpdate.Payload.Pending(None, None, wasInterrupted = true)
ctx.endpoint.sendToClient(
Api.Response(
Api.ExpressionUpdates(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ object TestMessages {
Vector(Api.ProfilingInfo.ExecutionTime(0)),
false,
true,
Api.ExpressionUpdate.Payload.PendingInterrupted
Api.ExpressionUpdate.Payload.Pending(None, None, wasInterrupted = true)
)
}
)
Expand Down

0 comments on commit 9cf67eb

Please sign in to comment.