Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Steps #17

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Introduce Steps #17

wants to merge 17 commits into from

Conversation

anronin
Copy link
Member

@anronin anronin commented Apr 24, 2022

No description provided.

@anronin anronin requested a review from Judis April 24, 2022 19:49
mix.exs Show resolved Hide resolved
end

def run_step(module, state) when is_atom(module) do
apply(module, :run, [state, []])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All is okay here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, what is wrong?

A step can be one of the following:

    * a 1-arity function

    * a `{module, function, args}` tuple - calls `apply(module, function, [state | args])`

    * a `{module, options}` tuple - calls `module.run(state, options)`

    * a `module` atom - calls `module.run(state, [])`

] ++
maybe_steps(options[:auth], [{__MODULE__, :auth, [options[:auth]]}]) ++
maybe_steps(options[:params], [{__MODULE__, :put_params, [options[:params]]}]) ++
maybe_steps(options[:steps], [{__MODULE__, :run_steps, [options[:steps]]}])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be we can reverse this operation and use [x|y] syntax?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed adding steps to request, can you look again?

response_telemetry_step = {__MODULE__, :log_response_end, []}

retry = options[:retry]
retry = if retry == true, do: [], else: retry
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we simplify that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can set retry: true then it will be default case:

retry only in case of exceptions (HTTPoison.Error and Mint.Error e.g. are exceptions) or status code >= 500, for 3 times with 2 sec pause

lib/http_client/steps.ex Outdated Show resolved Hide resolved
lib/http_client/steps.ex Show resolved Hide resolved
lib/http_client/steps.ex Show resolved Hide resolved
@anronin anronin force-pushed the add-steps branch 2 times, most recently from 0146390 to 02d00f9 Compare June 6, 2022 12:58
@anronin anronin force-pushed the add-steps branch 2 times, most recently from 6458b2d to be2cb9a Compare August 6, 2023 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants