From fef833f7f12d5e6cb2b972e87b8d5631b235fbf4 Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Mon, 8 Dec 2025 17:07:01 +0100 Subject: [PATCH 1/2] add a function to ChainlinkClient to read workflow events from http API --- framework/clclient/client.go | 20 ++++++++++++++++++++ framework/clclient/models.go | 21 +++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/framework/clclient/client.go b/framework/clclient/client.go index 1f1b63258..8d7c1f520 100644 --- a/framework/clclient/client.go +++ b/framework/clclient/client.go @@ -9,6 +9,7 @@ import ( "net/http" "os" "regexp" + "strconv" "strings" "sync" "time" @@ -1431,3 +1432,22 @@ func ImportP2PKeys(cl []*ChainlinkClient, keys [][]byte) error { } return eg.Wait() } + +func (c *ChainlinkClient) ReadWorkflowEvents(workflowID string, sequence int64, limit int) (*WorkflowDebugEvents, *http.Response, error) { + specObj := &WorkflowDebugEvents{} + framework.L.Info().Str(NodeURL, c.Config.URL).Str("ID", workflowID).Int64("sequence", sequence).Int("limit", limit).Msg("Reading Workflow Events") + resp, err := c.APIClient.R(). + SetResult(&specObj). + SetPathParams(map[string]string{ + "id": workflowID, + }). + SetQueryParams(map[string]string{ + "sequence": strconv.FormatInt(sequence, 10), + "limit": strconv.Itoa(limit), + }). + Get("/v2/debug/workflow/{id}/events?sequence={sequenceg}") + if err != nil { + return nil, nil, err + } + return specObj, resp.RawResponse, err +} diff --git a/framework/clclient/models.go b/framework/clclient/models.go index 69f9d9d93..df0b03b60 100644 --- a/framework/clclient/models.go +++ b/framework/clclient/models.go @@ -1419,3 +1419,24 @@ type ForwarderAttributes struct { CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` } + +type WorkflowDebugEvents struct { + Data WorkflowDebugEventsData `json:"data"` +} + +type WorkflowDebugEventsData struct { + Type string `json:"type"` + ID string `json:"id"` + Attributes WorkflowDebugEventsAttributes `json:"attributes"` +} + +type WorkflowDebugEventsAttributes struct { + Events []WorkflowDebugEvent `json:"events"` +} + +type WorkflowDebugEvent struct { + Timestamp time.Time `json:"timestamp"` + Sequence int64 `json:"sequence"` + Message []byte `json:"message"` // protobuf encoded + Type string `json:"type"` // protobuf type name +} From e27525ccd2af5978a19d38115ee311dfceb46fcb Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Tue, 9 Dec 2025 16:18:30 +0100 Subject: [PATCH 2/2] fix typo in sequence param, add support for orphan_events API --- framework/clclient/client.go | 18 +++++++++++++++++- framework/clclient/models.go | 21 +++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/framework/clclient/client.go b/framework/clclient/client.go index 8d7c1f520..90d1aa4bc 100644 --- a/framework/clclient/client.go +++ b/framework/clclient/client.go @@ -1445,7 +1445,23 @@ func (c *ChainlinkClient) ReadWorkflowEvents(workflowID string, sequence int64, "sequence": strconv.FormatInt(sequence, 10), "limit": strconv.Itoa(limit), }). - Get("/v2/debug/workflow/{id}/events?sequence={sequenceg}") + Get("/v2/debug/workflow/{id}/events?sequence={sequence}&limit={limit}") + if err != nil { + return nil, nil, err + } + return specObj, resp.RawResponse, err +} + +func (c *ChainlinkClient) ReadOrphanEvents(sequence int64, limit int) (*WorkflowOrphanEvents, *http.Response, error) { + specObj := &WorkflowOrphanEvents{} + framework.L.Info().Str(NodeURL, c.Config.URL).Int64("sequence", sequence).Int("limit", limit).Msg("Reading Workflow Orphan Events") + resp, err := c.APIClient.R(). + SetResult(&specObj). + SetQueryParams(map[string]string{ + "sequence": strconv.FormatInt(sequence, 10), + "limit": strconv.Itoa(limit), + }). + Get("/v2/debug/workflow/orphan_events?sequence={sequence}&limit={limit}") if err != nil { return nil, nil, err } diff --git a/framework/clclient/models.go b/framework/clclient/models.go index df0b03b60..5d8eaa794 100644 --- a/framework/clclient/models.go +++ b/framework/clclient/models.go @@ -1440,3 +1440,24 @@ type WorkflowDebugEvent struct { Message []byte `json:"message"` // protobuf encoded Type string `json:"type"` // protobuf type name } + +type WorkflowOrphanEvents struct { + Data WorkflowOrphanEventsData `json:"data"` +} + +type WorkflowOrphanEventsData struct { + Type string `json:"type"` + ID string `json:"id"` + Attributes WorkflowDebugEventsAttributes `json:"attributes"` +} + +type WorkflowOrphanEventsAttributes struct { + Events []WorkflowOrphanEvent `json:"events"` +} + +type WorkflowOrphanEvent struct { + Timestamp time.Time `json:"timestamp"` + Sequence int64 `json:"sequence"` + Message []byte `json:"message"` // protobuf encoded + Type string `json:"type"` // protobuf type name +}