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

MYST-272 CLI for connection statistics #124

Merged
merged 5 commits into from Jan 30, 2018

Conversation

Projects
None yet
3 participants
@donce
Copy link
Contributor

commented Jan 30, 2018

screen shot 2018-01-30 at 11 44 25

@donce donce force-pushed the feature/MYST-272-cli-connection-statistics branch from 3769348 to cd935ed Jan 30, 2018

@donce donce force-pushed the feature/MYST-272-cli-connection-statistics branch from cd935ed to c969681 Jan 30, 2018

}

info("Status:", status.Status)
info("SID:", status.SessionId)
statistics, err := c.tequilapi.ConnectionStatistics()

This comment has been minimized.

Copy link
@tadovas

tadovas Jan 30, 2018

Member

It would be nice if statistics are printed only if status == connected, otherwise - why to trash screen with not relevant information?

This comment has been minimized.

Copy link
@donce

donce Jan 30, 2018

Author Contributor

Updated

@@ -106,16 +106,28 @@ func (client *Client) Disconnect() (err error) {
return nil
}

// ConnectionStatistics returns statistics about current connection
func (client *Client) ConnectionStatistics() (statistics StatisticsDTO, err error) {

This comment has been minimized.

Copy link
@Waldz

Waldz Jan 30, 2018

Member

Should not it be getter?

This comment has been minimized.

Copy link
@donce

donce Jan 30, 2018

Author Contributor

It is a getter in a way, but it doesn't need Get prefix:
From https://golang.org/doc/effective_go.html#Getters:

it's neither idiomatic nor necessary to put Get into the getter's name. If you have a field called owner (lower case, unexported), the getter method should be called Owner (upper case, exported), not GetOwner

This comment has been minimized.

Copy link
@Waldz

Waldz Jan 30, 2018

Member

Cool.
Would be good to consistent in one object, I remember something like GetIP and GetStatus

response, err := client.http.Get("connection", url.Values{})
if err != nil {
return
}
defer response.Body.Close()

err = parseResponseJson(response, &status)
return status, err
return

This comment has been minimized.

Copy link
@Waldz

Waldz Jan 30, 2018

Member

Is it bad to have clearer declaration?

This comment has been minimized.

Copy link
@donce

donce Jan 30, 2018

Author Contributor

Since result parameters are named, I don't see much value added by rewriting the same named parameters here which is the default of return

This comment has been minimized.

Copy link
@donce

donce Jan 30, 2018

Author Contributor

Removed named parameters to reduce discussions on this.

type IdentityDto struct {
// StatisticsDTO holds statistics about connection
type StatisticsDTO struct {
BytesSent int `json:"bytesSent"`

This comment has been minimized.

Copy link
@Waldz

Waldz Jan 30, 2018

Member

For external users, I would name it uploadAmount and downloadAmount

This comment has been minimized.

Copy link
@donce

donce Jan 30, 2018

Author Contributor

"uploadAmount": 5 is a bit confusing - it doesn't specify units. But I like upload - what do you think about uploadedBytes and downloadedBytes ?

This comment has been minimized.

Copy link
@donce

donce Jan 30, 2018

Author Contributor

Applied naming we agreed on - renamed durationSeconds to duration, left byte fields unotuched.

type StatisticsDTO struct {
BytesSent int `json:"bytesSent"`
BytesReceived int `json:"bytesReceived"`
DurationSeconds int `json:"durationSeconds"`

This comment has been minimized.

Copy link
@Waldz

Waldz Jan 30, 2018

Member

Should we add ..seconds to attribute names?

This comment has been minimized.

Copy link
@donce

donce Jan 30, 2018

Author Contributor

It specifies unit in which these values are returned. i.e.:

{
"sent": 23,
"received": 54,
"duration": 3
}

This would not be easy to understand, because it's unclear what units these values are in.

@tadovas

This comment has been minimized.

Copy link
Member

commented Jan 30, 2018

LGTM

@Waldz

Waldz approved these changes Jan 30, 2018

@Waldz Waldz merged commit 2032775 into master Jan 30, 2018

@donce donce deleted the feature/MYST-272-cli-connection-statistics branch Jan 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.