indeedeng / iwf

iWF is a WorkflowAsCode microservice orchestration platform offering an orchestration coding framework and service for building resilient, fault-tolerant, scalable long-running processes
MIT License
540 stars 55 forks source link

Error invoking rpc in golang sdk #477

Open dennissetiawan opened 2 weeks ago

dennissetiawan commented 2 weeks ago

Hi i'm trying to invoke RPC in a state via unregistered client in go sdk

//RPC Definition
func (w MyWorkflow) Notification(ctx iwf.WorkflowContext, input iwf.Object, persistence iwf.Persistence, communication iwf.Communication) (interface{}, error) {

    ......
}

type initState struct {
    iwf.WorkflowStateDefaultsNoWaitUntil
    iwfClient iwf.UnregisteredClient
}

func (ths initState) Execute(ctx iwf.WorkflowContext, input iwf.Object, commandResults iwf.CommandResults, persistence iwf.Persistence, communication iwf.Communication) (*iwf.StateDecision, error) {
    ....
    ths.iwfClient.InvokeRPCByName(ctx, GetWorkflowID(inp.ID), "", "Notification", inp.ID, nil, nil).
    ....
}

But it returns 420 error in the iwf server.

In iwf server there is this log 2024-11-07 22:27:38 [GIN] 2024/11/07 - 15:27:38 | 420 | 19.007541ms | 172.18.0.1 | POST "/api/v1/workflow/rpc"

Did i get the rpc name and function call correctly?

longquanzheng commented 2 weeks ago

420 means that the invoking is successful but the worker(your application) got some error when execute it. Do you see some error there?

longquanzheng commented 2 weeks ago

Are you able to invoke rpc using Client(not unregistered) successfully? Just to make sure that RPC is registered and implemented correctly

longquanzheng commented 2 weeks ago

Testing it here: https://github.com/indeedeng/iwf-golang-sdk/pull/84/files