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

refactor(service): Add a ProgressHandler for the Wait interface #234

Closed
wants to merge 1 commit into from

Conversation

rhuss
Copy link
Contributor

@rhuss rhuss commented Jul 5, 2019

This remove the io.Writer from the client interface and replaces it with
ProgressHandler interface.

A SimpleProgressHandler instance can be used to print out the wait progress
on a writer.

This commit relies on that being PR #134 merged first.

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jul 5, 2019
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhuss

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 5, 2019
@knative-prow-robot knative-prow-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jul 5, 2019
@rhuss
Copy link
Contributor Author

rhuss commented Jul 5, 2019

/hold

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 5, 2019
@rhuss rhuss added this to the v0.2.0 milestone Jul 8, 2019
This remove the io.Writer from the client interface and replaces it with ProgressHandler interface.

A SimpleProgressHandler instance can be used to print out the wait progress on a writer.
@rhuss rhuss removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 8, 2019
@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 8, 2019
@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-client-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/wait/progress_handler.go Do not exist 100.0%
pkg/wait/wait_for_ready.go 81.0% 78.3% -2.7

@rhuss
Copy link
Contributor Author

rhuss commented Jul 8, 2019

/retest

Copy link
Contributor

@sixolet sixolet left a comment

Choose a reason for hiding this comment

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

One nit, one "do we have anything better?"

Otherwise good.

// Called with a percentage indicating completion
// The argument will be in the range 0..100 if the progress percentage can be calculated
// or -1 if only an ongoing operation should be indicated
Tic(complete int)
Copy link
Contributor

Choose a reason for hiding this comment

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

How about UpdateProgress instead of Tic? Or at least Tick?


// Printout ERROR label, but not the error.
// The error will be printed out later anyway
func (w *simpleProgressHandler) Fail(err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Unsure of this code. I feel like the contract "the progress handler will print an ERROR label but you-the-caller have to fill out the rest of the line" kind of splits responsibilities uncomfortably. Do we have any other reasonable options?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tbh, the handler is free to do what it wants to do with the error (so the documentation is misleading and explains the default implementation).

The contract is, that this method will be called when error occurs and the WaitForServce() method will return this error.

Thinking about this, maybe we don't even need the ProgressHandler as success/error can be easily handled based on the return value of the method (it's a synchronous method). Only for the progress indication (which we currently don't really use), we would need the callback, but the start and end indicators can be completely handled outside the method.

Let me check, how I can make that simpler.

rhuss added a commit to rhuss/knative-client that referenced this pull request Jul 8, 2019
This puts all the console output to the command, where it belongs too.
One could add a ProgressHandler for more fine granular feedback (like suggested in knative#234) but for now this is not needed.
@rhuss
Copy link
Contributor Author

rhuss commented Jul 8, 2019

I'm closing this PR in favour of #248 which is much simpler and achieves the same: Removing io.Writer from the KnClient interface.

In case we ever need a ProgressHandler to print out real progress (like watching and printing the various phases during startup), we could reintroduce this interface later again.

For now its just overkill. Thanks for the heads-up, @sixolet

@rhuss rhuss closed this Jul 8, 2019
knative-prow-robot pushed a commit that referenced this pull request Jul 8, 2019
#248)

This puts all the console output to the command, where it belongs too.
One could add a ProgressHandler for more fine granular feedback (like suggested in #234) but for now this is not needed.
coryrc pushed a commit to coryrc/client that referenced this pull request May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants