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

feat: Lens runtime config #2497

Merged
merged 3 commits into from
Apr 8, 2024

Conversation

nasdf
Copy link
Member

@nasdf nasdf commented Apr 5, 2024

Relevant issue(s)

Resolves #2496

Description

This PR adds a lens runtime option. It also includes some cleanup and additional tests.

Tasks

  • I made sure the code is well commented, particularly hard-to-understand areas.
  • I made sure the repository-held documentation is changed accordingly.
  • I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in tools/configs/chglog/config.yml).
  • I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, resource requirements, ...

How has this been tested?

make test

Specify the platform(s) on which this was tested:

  • MacOS

@nasdf nasdf self-assigned this Apr 5, 2024
@nasdf nasdf added the feature New feature or request label Apr 5, 2024
@nasdf nasdf added this to the DefraDB v0.11 milestone Apr 5, 2024
@nasdf nasdf requested a review from a team April 5, 2024 21:24
Copy link

codecov bot commented Apr 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.69%. Comparing base (4811ba9) to head (fb13730).

❗ Current head fb13730 differs from pull request most recent head 6c6676d. Consider uploading reports for the commit 6c6676d to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2497      +/-   ##
===========================================
+ Coverage    75.60%   75.69%   +0.08%     
===========================================
  Files          291      293       +2     
  Lines        28086    28078       -8     
===========================================
+ Hits         21234    21251      +17     
+ Misses        5496     5475      -21     
+ Partials      1356     1352       -4     
Flag Coverage Δ
all-tests 75.69% <100.00%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
db/config.go 100.00% <100.00%> (ø)
db/db.go 61.87% <100.00%> (-2.10%) ⬇️
lens/config.go 100.00% <100.00%> (ø)
lens/registry.go 83.66% <100.00%> (-0.08%) ⬇️

... and 15 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

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

type Option func(*db)

// WithACP enables access control. If path is empty then acp runs in-memory.
func WithACP(path string) Option {
Copy link
Contributor

Choose a reason for hiding this comment

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

thought: Seeing these 'new' ACP funcs was a surprise to me when reviewing, and there is not really any documentation in the PR description, and it is done in the same commit as the new Lens stuff. This forces reviewers to spend more time/energy figuring out what is existing stuff being moved, and what is new stuff being added. I suggest (in the future, not asking to to change this now) separate commits for this kind of stuff, and please be a little more explicit in the PR description as to what has been done.

lens/config.go Outdated
import "github.com/lens-vm/lens/host-go/engine/module"

// Option is a funtion that sets a config value on the lens registry.
type Option func(*lensRegistry)
Copy link
Contributor

Choose a reason for hiding this comment

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

todo: Please do not define public-public stuff (i.e. not just internal-public stuff) in the lens package. Users (or our integration tests) should not ever be referencing this package, and by adding stuff that requires the direct reference you are making the existing internal-public stuff public-public.

Please move these somewhere else, or given that they are setting private stuff, maybe have public-public funcs in client or db that call these internal-public functions, and make sure you remove the reference to this package from the integration tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

We should move the lens package into an internal sub-package if it's meant to be internal only.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this has been a long running battle, not everyone wants an internal package, although as far as I know everyone agrees that only a couple of packages are public. I created an issue for a proper internal package and we can discuss it in the standup - this conversation seems to happen every other month or so.

#2507

Copy link
Contributor

@AndrewSisley AndrewSisley Apr 8, 2024

Choose a reason for hiding this comment

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

To clarify, as far as I know, the fact that only a couple of packages are public is not really disputed by anyone - we all agree that public stuff can only live in client etc. What is disputed is whether that public/internal split should be enforced/documented by an internal directory or not. (so please move the public stuff out of the lens package in this PR)

Copy link
Contributor

@AndrewSisley AndrewSisley left a comment

Choose a reason for hiding this comment

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

I like the new db/config.go file, but please do not publicly expose the lens package, the public functions currently in there are not for external users.

Copy link
Contributor

@AndrewSisley AndrewSisley left a comment

Choose a reason for hiding this comment

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

LGTM, thanks Keenan, and sorry about the hassle/confusion RE lens/internal :)

size = lensPoolSize.Value()
} else {
size = DefaultPoolSize
func NewRegistry(
Copy link
Contributor

Choose a reason for hiding this comment

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

praise: The new param order makes a lot more sense, thanks for making db the first one :)

@@ -149,15 +107,12 @@ func newDB(

// apply options
for _, opt := range options {
if opt == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

praise: Thanks for removing this :)

@nasdf nasdf merged commit 2a63036 into sourcenetwork:develop Apr 8, 2024
26 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lens runtime db.Option
2 participants