Skip to content

Commit

Permalink
add support for optionally stalling/choking the ItemsCursor calling g…
Browse files Browse the repository at this point in the history
…o-routine on each call to get-items request (#130)
  • Loading branch information
assaf758 authored Jul 27, 2022
1 parent 54dfe2a commit e85be5e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/dataplane/itemscursor.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package v3io

import "time"

type ItemsCursor struct {
currentItem Item
currentError error
Expand Down Expand Up @@ -75,6 +77,10 @@ func (ic *ItemsCursor) NextItemSync() (Item, error) {
// get the previous request input and modify it with the marker
ic.getItemsInput.Marker = ic.nextMarker

if ic.getItemsInput.ChokeGetItemsMS != 0 {
time.Sleep(time.Duration(ic.getItemsInput.ChokeGetItemsMS) * time.Millisecond)
}

// invoke get items
newResponse, err := ic.container.GetItemsSync(ic.getItemsInput)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/dataplane/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ type GetItemsInput struct {
ReturnData string
DataMaxSize int
RequestJSONResponse bool `json:"RequestJsonResponse"`
ChokeGetItemsMS int
}

type GetItemsOutput struct {
Expand Down

0 comments on commit e85be5e

Please sign in to comment.