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

Add command line option -server.bindaddress #1102

Merged
merged 1 commit into from
Jun 29, 2022

Conversation

iils-jschmidt
Copy link
Contributor

This allows to specify the binding address of the fls in addition to the port.
If nothing is specified the wildcard 0.0.0.0 is used, that assumes to listen
on all available addresses.

Usage:
-server.bindaddress=192.168.123.123

This should also work with ipv6 addresses, however I cannot test this at the
moment.

The API Versions in ServerBindAdress.java have to be correct to the actual value.

Copy link
Contributor

@eparovyshnaya eparovyshnaya left a comment

Choose a reason for hiding this comment

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

Dear @JensGW
thank you very much to the handful improvement.

Unfortunately, if you do not have eclipse committer aggreement signed between you and Eclipse Foundation, you won't be able to commit to eclipse repository.

Can I take your contribution and commit it myself?

@@ -33,12 +35,14 @@ public JettyServer(Supplier<JettyHandler> handler) {
this.handler = handler;
}

public void launch(Port port) throws JettyException {
public void launch(ServerBindAddress serverBindAddress, Port port) throws JettyException {
Copy link
Contributor

Choose a reason for hiding this comment

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

we avoid compound variable names wherever we can. This should be named bind.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok will do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm. i would still suggest bindAddress. In contrast to port the word bind feels to unspecific, and only address is to abitrary.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please, choose any word you like, but if it is a variable or parameter, it must be a single word. Have a look around - there is hardly handful of compound names in the whole project.

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 agree on concise naming and being as short as possible. A convention should help guide and not enforce a inferior choice of name. In this specific case the variable name is the same as the command line argument, e.g. -server.port<->port and -server.bindaddress<->bindAddress.

First, the command line argument must not be shortened to -server.address because then the naming is unclear. One could assume it is an address the server should connect to over the network rather then bind to it itself and listen for connections on the binding address.

Then the variable name has to match the command line argument to make it clear that the argument's value ends up in the variable.

Second, just the word bind is out of scope, the variable does not describe a data strucutre that holds a bind to a network interface.

Therefore, please reconsider the name again.

Copy link
Contributor

@eparovyshnaya eparovyshnaya Jun 29, 2022

Choose a reason for hiding this comment

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

@JensGW

Command line argument is a part of user interface - it stays bindaddress.
Variable name has no obligation to match interface naming conventions: they are oriented to different purposes and pusue totally different goals - user interface must stay clear to an end user, source code must stay maintainable.

In the scope of Passage project, maintainability, besides architectural clarity, states the set of particular very formal rules. Compoud names discouraging is one of them.

Project code convention is not optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maintainability is important. However, a big part of maintaining is understanding the code. Names that are to long or to short make that task more difficult since the meaning has to be inferred from surrounding code instead of just read.
Restricting the naming to single words only greatly diminishes the expressiveness and precision which, in my opinion, makes maintainability more difficult. Having said that, I renamed the marked occurrences to a single word, see updated PR.

try {
server = Optional.of(new Server(port.get().get()));
InetSocketAddress addr = InetSocketAddress.createUnresolved(serverBindAddress.get().get(),
Copy link
Contributor

Choose a reason for hiding this comment

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

please rename to address

Copy link
Contributor Author

Choose a reason for hiding this comment

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

greed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed

private final LicenseProtection license = new LicenseProtection();
private final ServerBindAddress serverBindAddress;
Copy link
Contributor

Choose a reason for hiding this comment

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

compound name again

Copy link
Contributor

Choose a reason for hiding this comment

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

please pay attention to my comment above

@iils-jschmidt
Copy link
Contributor Author

Hi there,
hm, I signed the agreement but it does not seem to work.
Sure you can commit it yourself. Should I change the tings you remarked and update the PR?

@iils-jschmidt iils-jschmidt force-pushed the master branch 2 times, most recently from 2a5fa37 to 826c5db Compare June 28, 2022 15:18
@ruspl-afed
Copy link
Contributor

Thank you for your effort @JensGW

hm, I signed the agreement but it does not seem to work.

Please open Eclipse profile and specify your GitHub account there, it should do the trick

@eparovyshnaya eparovyshnaya self-requested a review June 28, 2022 16:19
@@ -33,12 +35,14 @@ public JettyServer(Supplier<JettyHandler> handler) {
this.handler = handler;
}

public void launch(Port port) throws JettyException {
public void launch(BindAddress bindAddress, Port port) throws JettyException {
Copy link
Contributor

Choose a reason for hiding this comment

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

compound names are prohibited in Passage Core with only exception for intentionally badly designed classes (like illustrative implementations for AccessCycleConfiguration)

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 agree on concise naming and being as short as possible. A convention should help guide and not enforce a inferior choice of name. In this specific case the variable name is the same as the command line argument, e.g. -server.port<->port and -server.bindaddress<->bindAddress.

First, the command line argument must not be shortened to -server.address because then the naming is unclear. One could assume it is an address the server should connect to over the network rather then bind to it itself and listen for connections on the binding address.

Then the variable name has to match the command line argument to make it clear that the argument's value ends up in the variable.

Second, just the word bind is out of scope, the variable does not describe a data strucutre that holds a bind to a network interface.

Therefore, please reconsider the name again.

Copy link
Contributor

Choose a reason for hiding this comment

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

please pay attention to my comment above

@iils-jschmidt
Copy link
Contributor Author

Thank you for your effort @JensGW

hm, I signed the agreement but it does not seem to work.

Please open Eclipse profile and specify your GitHub account there, it should do the trick

thx, that did the trick

/**
* @since 2.4
*/
public final class Listen extends CliParameter<String> {
Copy link
Contributor

Choose a reason for hiding this comment

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

cli-param describing class better be named BindAddress


import java.util.Optional;

//FIXME: correct since versions
Copy link
Contributor

Choose a reason for hiding this comment

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

since 2.5

@eparovyshnaya eparovyshnaya self-requested a review June 29, 2022 13:43
Copy link
Contributor

@eparovyshnaya eparovyshnaya left a comment

Choose a reason for hiding this comment

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

Two more compound names, all the rest is fine.

And.
As this looks as the first change of the bundle after recent release, piple will not be satisfied until you update service fragment bundle version. 0.1.300 will be fine.

org.eclipse.passage.lic.jetty: Only qualifier changed for (org.eclipse.passage.lic.jetty/0.1.200.v20220629-1247). Expected to have bigger x.y.z than what is available in baseline

@@ -62,16 +65,19 @@ public void restart() {

public void state() {
try {
String where = port.get().map(i -> i.toString()).orElse("-"); //$NON-NLS-1$
System.out.println(server.state() + " on port " + where); //$NON-NLS-1$
String usedBindAddress = listen.get().orElse("-"); //$NON-NLS-1$
Copy link
Contributor

Choose a reason for hiding this comment

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

compound names again

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here I am running out of names, it is the same thing in a different type, when I cannot compound I have to hide fields. See updated PR.

This allows to specify the binding address of the fls in
addition to the port. If nothing is specified the wildcard
0.0.0.0 is used, that assumes to listen on all available
addresses.

Usage:
-server.bindaddress=192.168.123.123

This should also work with ipv6 addresses, however I cannot
test this at the moment.
@eparovyshnaya
Copy link
Contributor

Thank you for your effort, @JensGW

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.

3 participants