Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Rename function for clarity
  • Loading branch information
tysonmote committed Jul 12, 2021
commit 28ae6688998801e36e75296018ba2e245e5605c0
5 changes: 2 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,15 @@ func New(writeKey string) *Client {
}

func NewWithConfig(writeKey string, config Config) *Client {
Copy link

Choose a reason for hiding this comment

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

What do you think if Config contains the writeKey?

func New(writeKey string) *Client {
  return NewWithConfig(Config{WriteKey: writeKey})
}

func NewWithConfig(config Config) *Client {
...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Configs tend to imply optionality. The writekey is not optional. I am not sure it belongs in the config

conf := getFinalConfig(config)
return &Client{
Config: conf,
Config: withDefaults(config),
writeKey: writeKey,
cmap: newConcurrentMap(),
semaphore: make(semaphore.Semaphore, 10),
}
}

func getFinalConfig(c Config) Config {
func withDefaults(c Config) Config {
if c.BaseEndpoint == "" {
c.BaseEndpoint = DefaultBaseEndpoint
}
Expand Down