docker-compose-wait
docker-compose-wait copied to clipboard
Allow host:port to accept connection url format
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.
- hostname: take the left part: rsplit on
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.
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 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)