Skip to content

Commit

Permalink
feat(agentctl): Support specific history seq num and improve layout (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrej-fabry committed Sep 3, 2020
1 parent 81772ea commit 487ee29
Show file tree
Hide file tree
Showing 13 changed files with 365 additions and 175 deletions.
3 changes: 2 additions & 1 deletion cmd/agentctl/api/types/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ type SchedulerResyncOptions struct {
}

type SchedulerHistoryOptions struct {
Count int
Count int
SeqNum int
}
12 changes: 12 additions & 0 deletions cmd/agentctl/client/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,27 @@ func (c *Client) SchedulerResync(ctx context.Context, opts types.SchedulerResync

func (c *Client) SchedulerHistory(ctx context.Context, opts types.SchedulerHistoryOptions) (api.RecordedTxns, error) {
query := url.Values{}
if opts.SeqNum >= 0 {
query.Set("seq-num", fmt.Sprint(opts.SeqNum))
}

resp, err := c.get(ctx, "/scheduler/txn-history", query, nil)
if err != nil {
return nil, err
}

if opts.SeqNum >= 0 {
var rectxn api.RecordedTxn
if err := json.NewDecoder(resp.body).Decode(&rectxn); err != nil {
return nil, fmt.Errorf("decoding reply failed: %v", err)
}
return api.RecordedTxns{&rectxn}, nil
}

var rectxn api.RecordedTxns
if err := json.NewDecoder(resp.body).Decode(&rectxn); err != nil {
return nil, fmt.Errorf("decoding reply failed: %v", err)
}

return rectxn, nil
}
Loading

0 comments on commit 487ee29

Please sign in to comment.