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

[dbnode] Ensure that bootstrap.Cache is always passed by reference #2703

Merged
merged 3 commits into from
Oct 7, 2020

Conversation

nbroyles
Copy link
Collaborator

@nbroyles nbroyles commented Oct 7, 2020

What this PR does / why we need it:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing and/or backwards incompatible change?:


Does this PR require updating code package or user-facing documentation?:


@@ -179,7 +179,7 @@ type readNamespaceResult struct {
func (s *commitLogSource) Read(
ctx context.Context,
namespaces bootstrap.Namespaces,
cache bootstrap.Cache,
cache *bootstrap.Cache,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: can be _

@@ -123,7 +123,7 @@ func newFileSystemSource(opts Options) (bootstrap.Source, error) {
func (s *fileSystemSource) AvailableData(
md namespace.Metadata,
shardTimeRanges result.ShardTimeRanges,
cache bootstrap.Cache,
cache *bootstrap.Cache,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: these can all be _

@@ -119,7 +119,7 @@ func (s *peersSource) AvailableIndex(
func (s *peersSource) Read(
ctx context.Context,
namespaces bootstrap.Namespaces,
cache bootstrap.Cache,
cache *bootstrap.Cache,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: these can be _

@@ -172,15 +172,15 @@ func TestPeersSourceAvailableDataAndIndex(t *testing.T) {
require.NoError(t, sErr)

runOpts := testDefaultRunOpts.SetInitialTopologyState(tc.topoState)
dataRes, err := src.AvailableData(nsMetadata, tc.shardsTimeRangesToBootstrap, cache, runOpts)
dataRes, err := src.AvailableData(nsMetadata, tc.shardsTimeRangesToBootstrap, &cache, runOpts)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: instead, could we have bootstrap.NewCache return a pointer?

@notbdu
Copy link
Contributor

notbdu commented Oct 7, 2020

Why don't we make bootstrap.Cache an iface and return a pointer to a type cache struct instead? We could potentially mock this and use a mock for testing in the future as well.

Should also require fewer changes but maybe some validation that cache is always set.

@@ -236,7 +236,7 @@ func (b bootstrapProcess) Run(
namespacesRunFirst,
namespacesRunSecond,
} {
res, err := b.runPass(ctx, namespaces, cache)
res, err := b.runPass(ctx, namespaces, &cache)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: should get this for free if NewCache returns a pointer

@nbroyles
Copy link
Collaborator Author

nbroyles commented Oct 7, 2020

Why don't we make bootstrap.Cache an iface and return a pointer to a type cache struct instead? We could potentially mock this and use a mock for testing in the future as well.

Should also require fewer changes but maybe some validation that cache is always set.

Yeah that's a good idea. Will do

Copy link
Collaborator

@ryanhall07 ryanhall07 left a comment

Choose a reason for hiding this comment

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

nice change to an interface!

Copy link
Collaborator

@robskillington robskillington left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@arnikola arnikola left a comment

Choose a reason for hiding this comment

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

LGTM

@nbroyles nbroyles merged commit 1f20f51 into master Oct 7, 2020
@nbroyles nbroyles deleted the nb/actually-use-cache-smh branch October 7, 2020 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants