Skip to content

Retry/polling mechanism for async resource creation #813

@igor-simoes

Description

@igor-simoes

Environment

  • Operating System: ubuntu
  • Python version: 3.11

What you intend to do with scanapi ?

Hi folks, first of all, thank you for this great tool.
We are planning to use it and wanted to know if there is a feature to automatically retry endpoint calls until a resource becomes available (similar to a polling mechanism). This would be necessary for creating asynchronous resources that start in a pending state and later transition to a created state.

Expected behavior ?

The client should automatically send subsequent GET requests to the appropriate endpoint URL to check the resource's current data. This polling behavior should be configurable through dedicated options. Since the retry key is already used for connection failures, I propose using polling as the key for this new feature:

endpoints:
  - name: my-api
    path: ${BASE_URL}
    requests:
      - name: get_item
        path: items/1
        polling:
          max_attempts: 5
          delay: 3000  # ms
          until: {{ response.json()["status"] == "created" }}  # sucess stop condition
          fail_when: {{ response.json()["status"] == "error" }}  # error stop condition
        tests:
          - !include tests/status_code_is_200.yaml

scanapi has a discord server so feel free to join and say 👋 hello. Maybe share the issue link?

Metadata

Metadata

Assignees

Labels

FeatureNew feature or requestSpecRelated with the API specification syntax

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions