-
Notifications
You must be signed in to change notification settings - Fork 8
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
Conversation
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok will do
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
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(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please rename to address
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
greed
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compound name again
There was a problem hiding this comment.
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
Hi there, |
2a5fa37
to
826c5db
Compare
Thank you for your effort @JensGW
Please open Eclipse profile and specify your GitHub account there, it should do the trick |
@@ -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 { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
thx, that did the trick |
/** | ||
* @since 2.4 | ||
*/ | ||
public final class Listen extends CliParameter<String> { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since 2.5
There was a problem hiding this 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$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compound names again
There was a problem hiding this comment.
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.
Thank you for your effort, @JensGW |
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.