Skip to content

Commit

Permalink
Fix all compling error
Browse files Browse the repository at this point in the history
  • Loading branch information
longquanzheng committed Sep 17, 2024
1 parent dcf9062 commit 66726c2
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 33 deletions.
6 changes: 3 additions & 3 deletions integ/timer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,20 @@ func doTestTimerWorkflow(t *testing.T, backendType service.BackendType, config *
}
assertions := assert.New(t)
timer2 := &service.TimerInfo{
CommandId: "timer-cmd-id-2",
CommandId: ptr.Any("timer-cmd-id-2"),
FiringUnixTimestampSeconds: nowTimestamp + 86400,
Status: service.TimerPending,
}
timer3 := &service.TimerInfo{
CommandId: "timer-cmd-id-3",
CommandId: ptr.Any("timer-cmd-id-3"),
FiringUnixTimestampSeconds: nowTimestamp + 86400*365,
Status: service.TimerPending,
}
expectedTimerInfos := service.GetCurrentTimerInfosQueryResponse{
StateExecutionCurrentTimerInfos: map[string][]*service.TimerInfo{
"S1-1": {
{
CommandId: "timer-cmd-id",
CommandId: ptr.Any("timer-cmd-id"),
FiringUnixTimestampSeconds: nowTimestamp + 10,
Status: service.TimerPending,
},
Expand Down
2 changes: 1 addition & 1 deletion integ/wait_for_state_completion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func doTestWaitForStateCompletion(
_, httpResp, err = req1.WorkflowWaitForStateCompletionRequest(
iwfidl.WorkflowWaitForStateCompletionRequest{
WorkflowId: wfId,
StateExecutionId: "S1-1",
StateExecutionId: ptr.Any("S1-1"),
WaitTimeSeconds: iwfidl.PtrInt32(30),
}).Execute()
panicAtHttpError(err, httpResp)
Expand Down
4 changes: 2 additions & 2 deletions integ/workflow/any_command_close/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ func (h *handler) ApiV1WorkflowStateStart(c *gin.Context) {
CommandRequest: &iwfidl.CommandRequest{
SignalCommands: []iwfidl.SignalCommand{
{
CommandId: "signal-cmd-id1",
CommandId: ptr.Any("signal-cmd-id1"),
SignalChannelName: SignalName1,
},
{
CommandId: "signal-cmd-id2",
CommandId: ptr.Any("signal-cmd-id2"),
SignalChannelName: SignalName2,
},
},
Expand Down
15 changes: 7 additions & 8 deletions integ/workflow/any_command_combination/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/indeedeng/iwf/gen/iwfidl"
"github.com/indeedeng/iwf/integ/workflow/common"
"github.com/indeedeng/iwf/service"
"github.com/indeedeng/iwf/service/common/ptr"
"log"
"net/http"
"time"
Expand Down Expand Up @@ -48,41 +49,39 @@ func (h *handler) ApiV1WorkflowStateStart(c *gin.Context) {

invalidTimerCommands := []iwfidl.TimerCommand{
{
CommandId: "",
FiringUnixTimestampSeconds: iwfidl.PtrInt64(time.Now().Unix() + 86400*365), // one year later
},
}
validTimerCommands := []iwfidl.TimerCommand{
{
CommandId: TimerId1,
CommandId: ptr.Any(TimerId1),
FiringUnixTimestampSeconds: iwfidl.PtrInt64(time.Now().Unix() + 86400*365), // one year later
},
}
invalidSignalCommands := []iwfidl.SignalCommand{
{
CommandId: "",
SignalChannelName: SignalNameAndId1,
},
{
CommandId: SignalNameAndId2,
CommandId: ptr.Any(SignalNameAndId2),
SignalChannelName: SignalNameAndId2,
},
}
validSignalCommands := []iwfidl.SignalCommand{
{
CommandId: SignalNameAndId1,
CommandId: ptr.Any(SignalNameAndId1),
SignalChannelName: SignalNameAndId1,
},
{
CommandId: SignalNameAndId1,
CommandId: ptr.Any(SignalNameAndId1),
SignalChannelName: SignalNameAndId1,
},
{
CommandId: SignalNameAndId2,
CommandId: ptr.Any(SignalNameAndId2),
SignalChannelName: SignalNameAndId2,
},
{
CommandId: SignalNameAndId3,
CommandId: ptr.Any(SignalNameAndId3),
SignalChannelName: SignalNameAndId3,
},
}
Expand Down
2 changes: 1 addition & 1 deletion integ/workflow/any_timer_signal/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (h *handler) ApiV1WorkflowStateStart(c *gin.Context) {
CommandRequest: &iwfidl.CommandRequest{
SignalCommands: []iwfidl.SignalCommand{
{
CommandId: "signal-cmd-id",
CommandId: ptr.Any("signal-cmd-id"),
SignalChannelName: SignalName,
},
},
Expand Down
5 changes: 3 additions & 2 deletions integ/workflow/interstate/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/indeedeng/iwf/gen/iwfidl"
"github.com/indeedeng/iwf/service"
"github.com/indeedeng/iwf/service/common/ptr"
"log"
"net/http"
"time"
Expand Down Expand Up @@ -68,7 +69,7 @@ func (h *handler) ApiV1WorkflowStateStart(c *gin.Context) {
DeciderTriggerType: iwfidl.ALL_COMMAND_COMPLETED.Ptr(),
InterStateChannelCommands: []iwfidl.InterStateChannelCommand{
{
CommandId: "cmd-1",
CommandId: ptr.Any("cmd-1"),
ChannelName: channel1,
},
},
Expand All @@ -82,7 +83,7 @@ func (h *handler) ApiV1WorkflowStateStart(c *gin.Context) {
DeciderTriggerType: iwfidl.ALL_COMMAND_COMPLETED.Ptr(),
InterStateChannelCommands: []iwfidl.InterStateChannelCommand{
{
CommandId: "cmd-2",
CommandId: ptr.Any("cmd-2"),
ChannelName: channel2,
},
},
Expand Down
7 changes: 3 additions & 4 deletions integ/workflow/signal/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/indeedeng/iwf/gen/iwfidl"
"github.com/indeedeng/iwf/integ/workflow/common"
"github.com/indeedeng/iwf/service"
"github.com/indeedeng/iwf/service/common/ptr"
"log"
"net/http"
)
Expand Down Expand Up @@ -46,19 +47,17 @@ func (h *handler) ApiV1WorkflowStateStart(c *gin.Context) {
CommandRequest: &iwfidl.CommandRequest{
SignalCommands: []iwfidl.SignalCommand{
{
CommandId: "signal-cmd-id0",
CommandId: ptr.Any("signal-cmd-id0"),
SignalChannelName: SignalName,
},
{
CommandId: "signal-cmd-id1",
CommandId: ptr.Any("signal-cmd-id1"),
SignalChannelName: SignalName,
},
{
CommandId: "",
SignalChannelName: SignalName,
},
{
CommandId: "",
SignalChannelName: SignalName,
},
},
Expand Down
7 changes: 4 additions & 3 deletions integ/workflow/timer/routers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package timer

import (
"github.com/indeedeng/iwf/service/common/ptr"
"log"
"net/http"
"strconv"
Expand Down Expand Up @@ -52,15 +53,15 @@ func (h *handler) ApiV1WorkflowStateStart(c *gin.Context) {
CommandRequest: &iwfidl.CommandRequest{
TimerCommands: []iwfidl.TimerCommand{
{
CommandId: "timer-cmd-id",
CommandId: ptr.Any("timer-cmd-id"),
DurationSeconds: iwfidl.PtrInt64(10), // fire after 10s
},
{
CommandId: "timer-cmd-id-2",
CommandId: ptr.Any("timer-cmd-id-2"),
DurationSeconds: iwfidl.PtrInt64(86400), // fire after one day
},
{
CommandId: "timer-cmd-id-3",
CommandId: ptr.Any("timer-cmd-id-3"),
DurationSeconds: iwfidl.PtrInt64(86400 * 365), // fire after one year
},
},
Expand Down
3 changes: 2 additions & 1 deletion integ/workflow/wait_for_state_completion/routers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wait_for_state_completion

import (
"github.com/indeedeng/iwf/service/common/ptr"
"log"
"net/http"
"strconv"
Expand Down Expand Up @@ -52,7 +53,7 @@ func (h *handler) ApiV1WorkflowStateStart(c *gin.Context) {
CommandRequest: &iwfidl.CommandRequest{
TimerCommands: []iwfidl.TimerCommand{
{
CommandId: "timer-cmd-id",
CommandId: ptr.Any("timer-cmd-id"),
FiringUnixTimestampSeconds: iwfidl.PtrInt64(now + 10), // fire after 10s
},
},
Expand Down
8 changes: 7 additions & 1 deletion service/api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,13 @@ func (s *serviceImpl) ApiV1WorkflowWaitForStateCompletion(
) (wresp *iwfidl.WorkflowWaitForStateCompletionResponse, retError *errors.ErrorAndStatus) {
defer func() { log.CapturePanic(recover(), s.logger, &retError) }()

workflowId := service.IwfSystemConstPrefix + req.WorkflowId + "_" + req.StateExecutionId
var workflowId string
if req.WaitForKey != nil {
workflowId = service.IwfSystemConstPrefix + req.WorkflowId + "_" + *req.WaitForKey
} else {
workflowId = service.IwfSystemConstPrefix + req.WorkflowId + "_" + *req.StateExecutionId
}

options := uclient.StartWorkflowOptions{
ID: workflowId,
TaskQueue: s.taskQueue,
Expand Down
4 changes: 2 additions & 2 deletions service/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ type (
}

TimerInfo struct {
CommandId string
CommandId *string
FiringUnixTimestampSeconds int64
Status InternalTimerStatus
}
Expand Down Expand Up @@ -186,7 +186,7 @@ func ValidateTimerSkipRequest(
}
if timerId != "" {
for _, t := range timerInfos {
if t.CommandId == timerId {
if t.CommandId != nil && *t.CommandId == timerId {
return t, true
}
}
Expand Down
6 changes: 3 additions & 3 deletions service/interpreter/deciderTriggerer.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ func IsDeciderTriggerConditionMet(
var completedCmdIds []string
for idx := range completedTimerCmds {
cmdId := commandReq.GetTimerCommands()[idx].CommandId
completedCmdIds = append(completedCmdIds, cmdId)
completedCmdIds = append(completedCmdIds, *cmdId)
}
for idx := range completedSignalCmds {
cmdId := commandReq.GetSignalCommands()[idx].CommandId
completedCmdIds = append(completedCmdIds, cmdId)
completedCmdIds = append(completedCmdIds, *cmdId)
}
for idx := range completedInterStateChannelCmds {
cmdId := commandReq.GetInterStateChannelCommands()[idx].CommandId
completedCmdIds = append(completedCmdIds, cmdId)
completedCmdIds = append(completedCmdIds, *cmdId)
}

for _, acceptedComb := range commandReq.GetCommandCombinations() {
Expand Down
5 changes: 3 additions & 2 deletions service/interpreter/workflowImpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
uclient "github.com/indeedeng/iwf/service/client"
"github.com/indeedeng/iwf/service/common/ptr"
"github.com/indeedeng/iwf/service/interpreter/env"
"time"

Expand Down Expand Up @@ -655,7 +656,7 @@ func executeState(
status = iwfidl.FIRED
}
timerResults = append(timerResults, iwfidl.TimerResult{
CommandId: cmd.GetCommandId(),
CommandId: ptr.Any(cmd.GetCommandId()),
TimerStatus: status,
})
}
Expand All @@ -672,7 +673,7 @@ func executeState(
}

signalResults = append(signalResults, iwfidl.SignalResult{
CommandId: cmd.GetCommandId(),
CommandId: ptr.Any(cmd.GetCommandId()),
SignalChannelName: cmd.GetSignalChannelName(),
SignalValue: result,
SignalRequestStatus: status,
Expand Down

0 comments on commit 66726c2

Please sign in to comment.