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

refactor: Decouple net config #2258

Merged
merged 7 commits into from
Jan 30, 2024

Conversation

nasdf
Copy link
Member

@nasdf nasdf commented Jan 26, 2024

Relevant issue(s)

Resolves #2263

Description

This is part of a larger refactor of the config package.

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 added the area/config Related to configuration label Jan 26, 2024
@nasdf nasdf self-assigned this Jan 26, 2024
Copy link

codecov bot commented Jan 26, 2024

Codecov Report

Attention: 10 lines in your changes are missing coverage. Please review.

Comparison is base (fb5c2ac) 73.94% compared to head (3327736) 74.05%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2258      +/-   ##
===========================================
+ Coverage    73.94%   74.05%   +0.11%     
===========================================
  Files          256      256              
  Lines        25770    25748      -22     
===========================================
+ Hits         19055    19066      +11     
+ Misses        5389     5364      -25     
+ Partials      1326     1318       -8     
Flag Coverage Δ
all-tests 74.05% <76.19%> (+0.11%) ⬆️

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

Files Coverage Δ
net/config.go 100.00% <100.00%> (+5.17%) ⬆️
config/config.go 74.19% <57.14%> (+0.06%) ⬆️
net/node.go 88.46% <80.00%> (-0.70%) ⬇️
cli/start.go 25.41% <50.00%> (-0.21%) ⬇️

... and 9 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 fb5c2ac...3327736. Read the comment docs.

@nasdf nasdf requested a review from a team January 26, 2024 23:06
Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

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

Nice work. Just one todo before approval :)

net/config.go Outdated
)

// Options is the node options.
type Options struct {
ListenAddrs []ma.Multiaddr
ListenAddress string
Copy link
Collaborator

Choose a reason for hiding this comment

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

todo: We need to be able to listen on multiple addresses. For example, we may want to listen on 0.0.0.0 to expose a port externally but alse listen on 127.0.0.1 so that we can have more than one node locally talking to each other.

Copy link
Member Author

Choose a reason for hiding this comment

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

Since one of the addresses will always be localhost could we just add an EnableLocalHost option here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's an option. I'm wondering if there may also be a situation where someone would want to listen on multiple ports 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

I've updated the config to support multiple addresses and set the default to localhost like we discussed.

Copy link
Member

@shahzadlone shahzadlone 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

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -36,7 +36,10 @@ net:
# Whether the P2P is disabled
p2pdisabled: {{ .Net.P2PDisabled }}
# Listening address of the P2P network
p2paddress: {{ .Net.P2PAddress }}
p2paddresses:
Copy link
Collaborator

Choose a reason for hiding this comment

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

thought: p2paddresses: {{ .Net.P2PAddresses }} would also work.

@nasdf nasdf merged commit 5834f81 into sourcenetwork:develop Jan 30, 2024
32 checks passed
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
## Relevant issue(s)
Resolves sourcenetwork#2263

## Description

This is part of a larger refactor of the config package.

## 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Net config refactor
3 participants