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

Allow host:port to accept connection url format #16

Open
vlcinsky opened this issue Nov 4, 2019 · 2 comments
Open

Allow host:port to accept connection url format #16

vlcinsky opened this issue Nov 4, 2019 · 2 comments

Comments

@vlcinsky
Copy link

vlcinsky commented Nov 4, 2019

Currently the specification of host and port must be in form "{host}:{port}".

In many cases the url to check is already present in the system configuration in form of connection parameter, e.g.: postgres://username:password@hostname:5432/database.

However, current implementation does not seem to accept such host and port specification.

Proposed solution:

  • require presence of explicit host and port in the url
  • rsplit the url on colon :
    • hostname: take the left part: rsplit on / or @, take the last element
    • port: take the right part, split on /, take the first element. Check that it includes only digits.

There are very likely better options, I just wanted to express that to me it seems very acceptable to require explicit hostname and port presence to keep the implementation small and simple.

@ufoscout
Copy link
Owner

ufoscout commented Nov 7, 2019

This could be an interesting proposal. Anyway, I would like to think about it a little more.
What is your use case exactly? Do you have a variable with the complete connection string and you want to reuse it?

@vlcinsky
Copy link
Author

vlcinsky commented Nov 7, 2019

@ufoscout yes, trying to follow 12-factor application principles, I have configuration parameters, one per backing service, e.g.:

  • postgresql url: postgres://user:password@db:5432/dbname
  • redis url: redis://user:password@redis_server:4433/0
  • rabbitmq url: amqp://user:password@messaging_server:9847/other/params?q=124

Keeping all configuration parameters for single backing service in one connection string seems practical as it can be handled as one item (one can argue, secrets shall be separated, but I would say the whole connection string could be considered a secret)

And my need is to test (on TCP level) availability of those backing services using just these urls. This I do before starting actual dependent process/application.

To keep implementation simple, I would require that the url must:

  • explicitly express the port (so that we can ignore the scheme prefix and relevant default ports for such scheme)
  • explicitly express the host (so that we can skip the decision, what is the default host)

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

No branches or pull requests

2 participants