-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CAPPL-128] limit the amount of fetch calls per request (#894)
* feat: limit the amount of fetch calls per request * fix: move counter to a request level * fix: define defaultMaxFetchRequests as a const * fix: rename and change type of fetchRequestsCounter
- Loading branch information
1 parent
8529bcc
commit fcae9bd
Showing
4 changed files
with
286 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
//go:build wasip1 | ||
|
||
package main | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/smartcontractkit/chainlink-common/pkg/workflows/wasm" | ||
|
||
"github.com/smartcontractkit/chainlink-common/pkg/capabilities/cli/cmd/testdata/fixtures/capabilities/basictrigger" | ||
"github.com/smartcontractkit/chainlink-common/pkg/workflows/sdk" | ||
) | ||
|
||
func BuildWorkflow(config []byte) *sdk.WorkflowSpecFactory { | ||
workflow := sdk.NewWorkflowSpecFactory( | ||
sdk.NewWorkflowParams{ | ||
Name: "tester", | ||
Owner: "ryan", | ||
}, | ||
) | ||
|
||
triggerCfg := basictrigger.TriggerConfig{Name: "trigger", Number: 100} | ||
trigger := triggerCfg.New(workflow) | ||
|
||
sdk.Compute1[basictrigger.TriggerOutputs, bool]( | ||
workflow, | ||
"transform", | ||
sdk.Compute1Inputs[basictrigger.TriggerOutputs]{Arg0: trigger}, | ||
func(rsdk sdk.Runtime, outputs basictrigger.TriggerOutputs) (bool, error) { | ||
|
||
for i := 0; i < 6; i++ { | ||
_, err := rsdk.Fetch(sdk.FetchRequest{ | ||
Method: http.MethodGet, | ||
URL: "https://min-api.cryptocompare.com/data/pricemultifull?fsyms=ETH&tsyms=BTC", | ||
}) | ||
if err != nil { | ||
return false, err | ||
} | ||
} | ||
|
||
return true, nil | ||
}) | ||
|
||
return workflow | ||
} | ||
func main() { | ||
runner := wasm.NewRunner() | ||
workflow := BuildWorkflow(runner.Config()) | ||
runner.Run(workflow) | ||
} |
Oops, something went wrong.