Skip to content
This repository has been archived by the owner on Aug 15, 2022. It is now read-only.

socialapi/countly: fix various stuff for countly client #10793

Merged
merged 1 commit into from Mar 17, 2017
Merged

Conversation

cihangir
Copy link
Contributor

No description provided.

if err != nil {
return err
}
defer resp.Body.Close()

return json.NewDecoder(resp.Body).Decode(&v)
}
b, err := ioutil.ReadAll(resp.Body)
Copy link
Member

Choose a reason for hiding this comment

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

What about setting some body limit?

const maxBody = 4 << 20

...

b, err := ioutil.ReadAll(io.LimitReader(resp.Body, maxBody))

Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to have nil v? (e.g. no payload)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What about setting some body limit?

even tho i am not sure at this point how much data we are going to fetch from countly api, 4<< 20 is a big number that we could assume as "safe". will add "LimitReader" ( i have only seen couple hundreds bytes of data received )

Is it possible to have nil v? (e.g. no payload)

didnt check their whole api yet, hence it is hidden under our worker not public/standalone

return *v, err
// CreateApp creates an app with admin key.
func (c *Client) CreateApp(app *App) (*App, error) {
if app.Name == "" {
Copy link
Member

@rjeczalik rjeczalik Mar 17, 2017

Choose a reason for hiding this comment

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

What about moving all the validation to a separate (*App).Valid() error?

return nil, err
// CreateUser creates a user with admin credentials.
func (c *Client) CreateUser(info *User) (*User, error) {
if info.FullName == "" {
Copy link
Member

@rjeczalik rjeczalik Mar 17, 2017

Choose a reason for hiding this comment

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

What about moving all the validation to a separate (*User).Valid() error?

v := new(Apps)
err := c.do("GET", "/o/apps/mine", values, &v)
v := new(App)
err := c.do("GET", "/i/apps/create", values, &v)
Copy link
Contributor

Choose a reason for hiding this comment

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

it's a matter of taste but I prefer http.MethodGet instead of "GET"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i prefer it like that too, will update.

)

var (
defaultDomainURL = "http://localhost:32768"
Copy link
Contributor

Choose a reason for hiding this comment

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

can it be const?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will convert it to const

}

for _, option := range opts {
option(client)
}

if client.log == nil {
logging.NewCustom("countly client", false)
Copy link
Contributor

Choose a reason for hiding this comment

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

client.log = logging.NewCustom(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤦‍♂️

@cihangir
Copy link
Contributor Author

i have cherrypicked this commit to other PRs, lets merge this PR after it passed and i will send another PR, works for you guys?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants