Skip to content

Commit

Permalink
Fix callback cli message when promise is already completed (#503)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfarr authored Dec 27, 2024
1 parent cc66e51 commit 1141959
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion cmd/callbacks/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"errors"
"strings"
"time"

"github.com/resonatehq/resonate/pkg/client"
Expand Down Expand Up @@ -73,7 +74,11 @@ func CreateCallbackCmd(c client.Client) *cobra.Command {
if res.StatusCode() == 201 {
cmd.Printf("Created callback: %s\n", id)
} else if res.StatusCode() == 200 {
cmd.Printf("Created callback: %s (deduplicated)\n", id)
if res.JSON200.Promise != nil && res.JSON200.Promise.State != v1.PromiseStatePENDING {
cmd.Printf("Promise %s already %s\n", promiseId, strings.ToLower(string(res.JSON200.Promise.State)))
} else {
cmd.Printf("Created callback: %s (deduplicated)\n", id)
}
} else {
cmd.PrintErrln(res.Status(), string(res.Body))
}
Expand Down
2 changes: 1 addition & 1 deletion test/dst/dst.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func (d *DST) Run(r *rand.Rand, api api.API, aio aio.AIO, system *system.System)
func (d *DST) logNonLinearizable(ops []porcupine.Operation, history porcupine.LinearizationInfo) {
// log the linearizations
linearizations := history.PartialLinearizationsOperations()
util.Assert(len(linearizations) == 3, "linearizations must be equal to the number of partitions")
util.Assert(len(linearizations) == 4, "linearizations must be equal to the number of partitions")

// check each parition individually
// partitions are in order: promise, schedule, lock
Expand Down

0 comments on commit 1141959

Please sign in to comment.