Skip to content

Commit fef833f

Browse files
committed
add a function to ChainlinkClient to read workflow events from http API
1 parent 4c45835 commit fef833f

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

framework/clclient/client.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"net/http"
1010
"os"
1111
"regexp"
12+
"strconv"
1213
"strings"
1314
"sync"
1415
"time"
@@ -1431,3 +1432,22 @@ func ImportP2PKeys(cl []*ChainlinkClient, keys [][]byte) error {
14311432
}
14321433
return eg.Wait()
14331434
}
1435+
1436+
func (c *ChainlinkClient) ReadWorkflowEvents(workflowID string, sequence int64, limit int) (*WorkflowDebugEvents, *http.Response, error) {
1437+
specObj := &WorkflowDebugEvents{}
1438+
framework.L.Info().Str(NodeURL, c.Config.URL).Str("ID", workflowID).Int64("sequence", sequence).Int("limit", limit).Msg("Reading Workflow Events")
1439+
resp, err := c.APIClient.R().
1440+
SetResult(&specObj).
1441+
SetPathParams(map[string]string{
1442+
"id": workflowID,
1443+
}).
1444+
SetQueryParams(map[string]string{
1445+
"sequence": strconv.FormatInt(sequence, 10),
1446+
"limit": strconv.Itoa(limit),
1447+
}).
1448+
Get("/v2/debug/workflow/{id}/events?sequence={sequenceg}")
1449+
if err != nil {
1450+
return nil, nil, err
1451+
}
1452+
return specObj, resp.RawResponse, err
1453+
}

framework/clclient/models.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,3 +1419,24 @@ type ForwarderAttributes struct {
14191419
CreatedAt time.Time `json:"createdAt"`
14201420
UpdatedAt time.Time `json:"updatedAt"`
14211421
}
1422+
1423+
type WorkflowDebugEvents struct {
1424+
Data WorkflowDebugEventsData `json:"data"`
1425+
}
1426+
1427+
type WorkflowDebugEventsData struct {
1428+
Type string `json:"type"`
1429+
ID string `json:"id"`
1430+
Attributes WorkflowDebugEventsAttributes `json:"attributes"`
1431+
}
1432+
1433+
type WorkflowDebugEventsAttributes struct {
1434+
Events []WorkflowDebugEvent `json:"events"`
1435+
}
1436+
1437+
type WorkflowDebugEvent struct {
1438+
Timestamp time.Time `json:"timestamp"`
1439+
Sequence int64 `json:"sequence"`
1440+
Message []byte `json:"message"` // protobuf encoded
1441+
Type string `json:"type"` // protobuf type name
1442+
}

0 commit comments

Comments
 (0)