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

Move internal/x/settings to internal/settings #77

Merged
merged 6 commits into from
Jun 11, 2018
Merged

Move internal/x/settings to internal/settings #77

merged 6 commits into from
Jun 11, 2018

Conversation

bufdev
Copy link
Contributor

@bufdev bufdev commented May 14, 2018

No description provided.

@codecov-io
Copy link

codecov-io commented May 14, 2018

Codecov Report

Merging #77 into dev will decrease coverage by 0.24%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev      #77      +/-   ##
==========================================
- Coverage   67.88%   67.63%   -0.25%     
==========================================
  Files          68       68              
  Lines        3783     3726      -57     
==========================================
- Hits         2568     2520      -48     
+ Misses        880      874       -6     
+ Partials      335      332       -3
Impacted Files Coverage Δ
internal/x/protoc/protoc.go 36.58% <ø> (ø) ⬆️
internal/x/exec/runner.go 44.14% <ø> (ø) ⬆️
internal/x/file/file.go 62.5% <ø> (ø) ⬆️
internal/settings/settings.go 66.66% <ø> (ø)
internal/x/format/format.go 100% <ø> (ø) ⬆️
internal/x/format/first_pass_visitor.go 68.18% <ø> (ø) ⬆️
internal/x/protoc/compiler.go 46.43% <ø> (ø) ⬆️
internal/x/format/middle_visitor.go 87.89% <ø> (ø) ⬆️
internal/x/file/proto_set_provider.go 68.07% <ø> (ø) ⬆️
internal/x/format/transformer.go 82.05% <ø> (ø) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a697071...aa2704e. Read the comment docs.

filePathToConfig map[string]Config
dirPathToFilePath map[string]string
dirPathToExcludePrefixes map[string][]string
lock sync.RWMutex
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a lot of logic written around making the configProvider concurrent-safe. Is this really necessary? In the places that this might be called concurrently, such as in calls in internal/x/file, can we instead synchronously run the commands?

I'm not sure how much of a performance gain we expect to see in this domain, so it might be worth removing it for now.

What do you think? Is this actually completely necessary / am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Things like caches (which is what this is locking) should always be thread-safe, IMO, I don't see it as an optional thing. I don't want our designs to have to rely on something being not thread-safe, or worse, someone using this in a deep dependency in a threaded manner without realizing this is not thread-safe. It's defensive programming if anything, but a cache should generally always be thread-safe unless there's a compelling reason not to be IMO.

@bufdev
Copy link
Contributor Author

bufdev commented May 23, 2018

I ripped out the caching in e85e696 - it actually doesn't clean it up that much, but it doesn't seem to make any difference in time when I run it against googleapis. I'll play with it more but do you like this more?

// The prefixes to exclude.
// Expected to be absolute paths.
// Expected to be unique.
ExcludePrefixes []string
Copy link
Contributor

Choose a reason for hiding this comment

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

Thoughts on renaming this Blacklist?

// It is meant to be set by a YAML or JSON config file, or flags.
type ExternalConfig struct {
Excludes []string `json:"excludes,omitempty" yaml:"excludes,omitempty"`
NoDefaultExcludes bool `json:"no_default_excludes,omitempty" yaml:"no_default_excludes,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Re: #49 -

Should we remove this?

includePath = filepath.Join(dirPath, includePath)
}
includePath = filepath.Clean(includePath)
//if includePath != dirPath {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we remove this?

@amckinney
Copy link
Contributor

I prefer the implementation without the cache, especially because I don't know how often we need to retrieve a configuration for the same file path (rather than simply accessing the configuration that was already retrieved once). It does, however, make it so that we will unmarshal the yaml every time the file path is requested.

I'm not saying that we should do this here, but we should consider the prototool.yaml hierarchy and determine whether or not we should stick to the current tree/override behavior. More details #93

@@ -28,27 +28,19 @@ import (
"sort"
"strconv"
"strings"
"sync"

"github.com/uber/prototool/internal/strs"
"go.uber.org/zap"
"gopkg.in/yaml.v2"
)

type configProvider struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Now that the cache is removed, it looks like we don't actually need this type. The logger is never used and all of the configProvider methods don't access any of the type's attributes. In other words, all of the methods could be package-level functions now.

Removing this later might become more relevant depending on the direction we take #93. If we only ever need one prototool.yaml, simple package-level functions might make more sense since we only need the single configuration struct.

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 still want to keep this abstraction for now, but we can revisit after #93.

Copy link
Contributor

@amckinney amckinney left a comment

Choose a reason for hiding this comment

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

Looks good. Let's come back to some of this when we take a closer look at #12 and #93.

@bufdev bufdev merged commit 0b67e8e into dev Jun 11, 2018
@bufdev bufdev deleted the settings branch June 11, 2018 16:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants