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

Node options are not fully composable #2642

Closed
AndrewSisley opened this issue May 22, 2024 · 0 comments · Fixed by #2648
Closed

Node options are not fully composable #2642

AndrewSisley opened this issue May 22, 2024 · 0 comments · Fixed by #2648
Assignees
Labels
area/config Related to configuration code quality Related to improving code quality feature New feature or request

Comments

@AndrewSisley
Copy link
Contributor

Node options cannot safely be appended, as the inner slices overwrite each other instead of appending.

For example, db options are a slice:

type Options struct {
	dbOpts     []db.Option
}

And WithDatabaseOpts overwrites this slice:

func WithDatabaseOpts(opts ...db.Option) NodeOpt {
	return func(o *Options) {
		o.dbOpts = opts
	}
}

This means that one cannot do:

opts := []node.NodeOpt{}
opts = append(opts, WithDatabaseOpts(node.WithUpdateEvents())
...
opts = append(opts, WithDatabaseOpts(db.WithLensPoolSize(lensPoolSize))

As the result would be a db with no update events.

This limits consuming code and risks bugs, both for us (e.g. during test setup), and for any users wishing to use embedded defra.

@AndrewSisley AndrewSisley added feature New feature or request code quality Related to improving code quality area/config Related to configuration labels May 22, 2024
@nasdf nasdf self-assigned this May 23, 2024
nasdf added a commit that referenced this issue May 24, 2024
## Relevant issue(s)

Resolves #2642 

## Description

This PR fixes an issue where node subsystem options were not composable.

## Tasks

- [x] I made sure the code is well commented, particularly
hard-to-understand areas.
- [x] I made sure the repository-held documentation is changed
accordingly.
- [x] 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](tools/configs/chglog/config.yml)).
- [x] 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
ChrisBQu pushed a commit to ChrisBQu/defradb that referenced this issue Feb 21, 2025
## Relevant issue(s)

Resolves sourcenetwork#2642 

## Description

This PR fixes an issue where node subsystem options were not composable.

## Tasks

- [x] I made sure the code is well commented, particularly
hard-to-understand areas.
- [x] I made sure the repository-held documentation is changed
accordingly.
- [x] 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](tools/configs/chglog/config.yml)).
- [x] 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/config Related to configuration code quality Related to improving code quality feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants