Make broker flag configurable - #479
Conversation
soffokl
left a comment
There was a problem hiding this comment.
Do we really need an extra flag for broker port?
Why broker address can't be a single line testnet-broker.mysterium.network:4222?
|
Yes @soffokl that was also suggested by @zyfdegh in issue #226. @Waldz suggested a separate option. My guess is this is to fit in with but discovery address uses this method So we have an inconsistency here. We should make it all uniform right? Either the port is accepted as part of the address for all addresses or for none. My vote, for what its worth, goes with having the port as part of the address 'host:port' as is convention within the |
|
What do you rekon @Waldz, I'll re-spin after you've made a call. |
|
I am for Because, service provider will have several contacts where he announces service proposal: |
|
Hey @Waldz could you explain your work flow to me please. When you merge master into a pull request like done here what do you expect me to do when I go to update the PR?
In this case it doesn't matter because the whole PR will change but this happened once before and confused me also. thanks man |
|
Updated this PR completely:
Currently we do not handle command line option Fix handling of |
|
|
||
| url, err := url.Parse(rawurl) | ||
| if err != nil { | ||
| return nil |
There was a problem hiding this comment.
We should not just hide an error.
I'd change the function to return the error, and stop the application if the provided address was incorrect.
There was a problem hiding this comment.
I actually did that at first. Then I thought that perhaps it was the callers responsibility to pass in a valid string. Caller can still tell we failed by checking if returned string is "". This imitates the way at least one function in the standard library works (I can't think which one off the top of my head though). Doing it this way will mean we could verify the option strings when the myst command first starts. This makes the rest of the code more simple since we know we have valid option strings. What do you think?
There was a problem hiding this comment.
Function naming. GenerateNewAddress ?
There was a problem hiding this comment.
I'll agree with Dmitry - it's best to return the error here. Having to check for an empty string does not feel like a Go way of doing things. I'd stick with the error being returned and the good old if err != nil.
There was a problem hiding this comment.
Looks like we have consensus on this then. Will re-do with an error return. Thanks
There was a problem hiding this comment.
@tcharding replying to your question - yes I think GenerateNewAddress is a better name.
There was a problem hiding this comment.
lol, my dislexia was playing up @tadovas I read your original comment a bunch of times before and didn't realize you had switched the word Generate from the back of the function name to the front. Thanks for clarifying.
|
|
||
| url, err := url.Parse(rawurl) | ||
| if err != nil { | ||
| return nil |
There was a problem hiding this comment.
Function naming. GenerateNewAddress ?
|
|
||
| url, err := url.Parse(rawurl) | ||
| if err != nil { | ||
| return nil |
There was a problem hiding this comment.
I'll agree with Dmitry - it's best to return the error here. Having to check for an empty string does not feel like a Go way of doing things. I'd stick with the error being returned and the good old if err != nil.
implies that you should use |
This seems to add weight to the idea of doing some sort of verification on this option string (possibly when the command starts). Did you want me to drop the use of 'nats' from the commit log @zolia?
@tadovas I don't understand this comment sorry. Do you mean you don't like this function name? |
from my understanding it should simply be: |
`golint` emits warnings: interface method parameter sessionId should be sessionID method parameter sessionId should be sessionID We should us capital letters for acronyms as is standard golang convention. After this is applied server/ lints cleanly. Use sessionID instead of sessionId for parameter. Signed-off-by: tcharding <me@tobin.cc>
We currently have four functions for creating a NATS address NewAddress NewAddressGenerate NewAddressForContact newAddressWithConnection `NewAddressGenerate` is not overly clear, lets rename it. In order to fit in with the other function names use `NewAddressFromHostAndID`. Signed-off-by: tcharding <me@tobin.cc>
Add table driven testing to `nats/discovery`. Signed-off-by: tcharding <me@tobin.cc>
Currently we unconditionally add `nats://` scheme to address string of the broker. It is reasonable for the user to expect to be able to pass an address of form `nats://localhost` when configuring the broker. Only add the scheme `nats:` if it is not already present in the URI. Signed-off-by: tcharding <me@tobin.cc>
In preparation for additional NATS address construction logic add an error return to the `DialogWaiterFactory`. Signed-off-by: tcharding <me@tobin.cc>
Currently we add the hard coded broker port number 4222
unconditionally. If a user wishes to configure nats to use a different
port number then we need to accept this port number as part of the
configuration for running myst. If we conditionally add the port number
then the following is supported
bin/run --broker-addres="localhost:3333"
It seems that nats library should handle an address string that does not
contain the port number by using the default port but our e2e tests fail
if the port number is not present.
Conditionally add broker port number to the address string.
Signed-off-by: tcharding <me@tobin.cc>
Use `URI` and `URL` to be precise in what we accept for the broker address and the discovery service address. Also use backticks so that `URI`/`URL` shows up in the help menu instead of `value`. Signed-off-by: tcharding <me@tobin.cc>
Currently we have help output `Url`, we should use capitals for acronyms here as we do in the rest of the help menu. Capitalise Url in help output, se 'URL' instead of 'Url'. Signed-off-by: tcharding <me@tobin.cc>
|
@tadovas I used function name Please review the changes to the help menu output since this is the first use of the back ticks. Has there been discussion already on this usage? thanks |
|
@Waldz could you please remove WIP label (no longer 'Work in Progress') thanks. |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
@tadovas @zolia @vkuznecovas @Waldz Let's review this once again. Changes look reasonable, but it took too long without any actions. |
|
I'll fix CI, so it's ready to review. |
a268982
Currently broker flag is hard coded as 4222. We can make it configurable by adding an option
--broker-port.Make broker flag configurable.
Closes #226
Testing
PR is untested. With the following patch applied and running
bin/localnet/setup.shI can confirm port is openI cannot really work out ATM how to do further testing using the local net. I'm a bit confused by
bin/run daemonvsbin/run service. (I've not got localnet running on master branch either.)Signed-off-by: Tobin C. Harding me@tobin.cc