docker-compose-wait icon indicating copy to clipboard operation
docker-compose-wait copied to clipboard

Allow host:port to accept connection url format

Open vlcinsky opened this issue 6 years ago • 2 comments

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.

vlcinsky avatar Nov 04 '19 23:11 vlcinsky

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?

ufoscout avatar Nov 07 '19 09:11 ufoscout

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

vlcinsky avatar Nov 07 '19 09:11 vlcinsky