You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// OutputReader interface is used to read the websocket output from the stream
typeOutputReaderinterface {
// Read is called when a websocket message is received
Read(messageTypeint, 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.
The text was updated successfully, but these errors were encountered:
GetOutput
currently accepts antype OutputReader interface
, which the caller must implement:scs-build-client/client/output.go
Lines 18 to 22 in 3907a92
The
messageType int
here is problematic, because it requires the caller to understand implementation details. In particular, the caller needs to understand the possiblemessageType
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:
To this:
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 asos.Stdout
, simplifying usage.The text was updated successfully, but these errors were encountered: