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

Simplify GetOutput #65

Closed
tri-adam opened this issue Mar 1, 2022 · 0 comments · Fixed by #66
Closed

Simplify GetOutput #65

tri-adam opened this issue Mar 1, 2022 · 0 comments · Fixed by #66
Assignees
Labels
enhancement New feature or request

Comments

@tri-adam
Copy link
Member

tri-adam commented Mar 1, 2022

GetOutput currently accepts an type OutputReader interface, which the caller must implement:

// OutputReader interface is used to read the websocket output from the stream
type OutputReader interface {
// Read is called when a websocket message is received
Read(messageType int, p []byte) (int, error)
}

The messageType int here is problematic, because it requires the caller to understand implementation details. In particular, the caller needs to understand the possible messageType values, and how to handle them. In practice, these are defined as "text" and "binary" in RFC 6455. All implementations that I could find handle text messages, and discard binary ones.

With all that in mind, I propose we change the signature from this:

func (c *Client) GetOutput(ctx context.Context, buildID string, or OutputReader) error

To this:

func (c *Client) GetOutput(ctx context.Context, buildID string, w io.Writer) error

This way, the caller doesn't need to worry about any of the web socket implementation details under the hood, and can pass any io.Writer such as os.Stdout, simplifying usage.

@tri-adam tri-adam added the enhancement New feature or request label Mar 1, 2022
@tri-adam tri-adam self-assigned this Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant