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

added client and header timeout. #19

Merged
merged 1 commit into from
Jan 14, 2022

Conversation

csalvo9
Copy link
Contributor

@csalvo9 csalvo9 commented Jan 14, 2022

This PR adds 2 new methods:

SetHeaderTimeout(int)
This sets the response header timeout (in seconds) for the http transport.

SetClientTimeout(int)
This sets the command timeout (in seconds). Default is 30 seconds (same as before).

These new timeout values are set in callAPI() during transport / http client init.

This PR also changes the call to callAPI from:
resp, err := callAPI("jsonrpc", url, payload, cli.username, cli.password, .......)
to:
resp, err := cli.callAPI("jsonrpc", url, payload)

@greenpau
Copy link
Owner

@csalvo9 , thank you for contributing! 👍

Please change

func callAPI(contentType string, url string, payload []byte, username, password string, secure bool) ([]byte, error) {

to:

func (cli *Client) callAPI(contentType string, url string, payload []byte)

This way, instead of:

resp, err := callAPI("jsonrpc", url, payload, cli.username, cli.password, cli.secure, cli.headerTimeout, cli.clientTimeout)

You will do:

resp, err := cli.callAPI("jsonrpc", url, payload)

@greenpau greenpau self-requested a review January 14, 2022 17:37
pkg/client/client.go Outdated Show resolved Hide resolved
@csalvo9 csalvo9 force-pushed the added_client_and_hdr_timeout branch from 04feb3b to 8074058 Compare January 14, 2022 19:30
Copy link
Owner

@greenpau greenpau left a comment

Choose a reason for hiding this comment

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

@csalvo9 , LGTM 👍

@greenpau greenpau merged commit 31913b5 into greenpau:main Jan 14, 2022
@greenpau
Copy link
Owner

@csalvo9 , if you have energy, please see if you could resolve #6?

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.

2 participants