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

Adding httpx as a library minimal example #670

Merged
merged 1 commit into from
Jun 28, 2022
Merged

Conversation

Mzack9999
Copy link
Member

Description

This PR contains updated documentation with a minimal example of how to use httpx as a library and an integration test.
The runner API needs a major rework to separate the execution logic from gologger/goflags/CLI dependency. The following changes would be required and will be handled into independent follow-up tickets:

  • Input stream via channel
  • Adding context support (hence support for cancelation/deadline/timeout)
  • Output stream via channel

@Mzack9999 Mzack9999 added documentation Improvements or additions to documentation Type: Enhancement Most issues will probably ask for additions or changes. labels Jun 21, 2022
@Mzack9999 Mzack9999 self-assigned this Jun 21, 2022
@Mzack9999 Mzack9999 linked an issue Jun 21, 2022 that may be closed by this pull request
@Mzack9999 Mzack9999 mentioned this pull request Jun 21, 2022
@jimen0
Copy link
Contributor

jimen0 commented Jun 21, 2022

Hi @Mzack9999 - Does this PR mean there will be a major version bump for httpx? This is a public facing API change:

- func (options *Options) validateOptions() {
+ func (options *Options) ValidateOptions() error {

Please, note any wrapped error returned from an exported method automatically becomes part of your API.

	if options.matchContentLength, err = stringz.StringToSliceInt(options.OutputMatchContentLength); err != nil {
- 		gologger.Fatal().Msgf("Invalid value for match content length option: %s\n", err)
+ 		return errors.Wrap(err, "Invalid value for match content length option")

Do you want stringz package errors to become part of httpx/runner API? It sounds more like an internal package instead.

Happy to beta-test the new httpx public API once it's ready before a new version is tagged, by the way!

@Mzack9999
Copy link
Member Author

@jimen0 Thanks for having a look at this. I intended to expose validation errors to the caller, as the runner might be embedded into third-party code.
To make it more usable, I think some part needs to be refactored since now the whole structure is built around the concept of a command-line tool, so indeed, I'm sure there will be a significant version bump. As this is a big task, I opted for closing this issue with a basic demo example of how to run the current version within go code and later handle significant changes into separate issues since I think the changes and refactoring will require some work.
I listed a few things I think can be a good starting point in my first comment at #670 (comment). Happy to discuss if you think we can approach the problem differently or if there are better practical ways to expose the public runner's API.

@ehsandeep ehsandeep merged commit e4e2aab into dev Jun 28, 2022
@ehsandeep ehsandeep deleted the issue-592-api-interface branch June 28, 2022 10:49
@ehsandeep ehsandeep added the Status: Completed Nothing further to be done with this issue. Awaiting to be closed. label Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation Status: Completed Nothing further to be done with this issue. Awaiting to be closed. Type: Enhancement Most issues will probably ask for additions or changes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using httpx as go code
4 participants