Open thothothotho opened 3 years ago
It is now very convenient to configure a Influx client with a server url. Most Influx client libraries support that.
At the moment, the client API is that:
def __init__(self, host='localhost', port=8086, username='root', password='root', database=None, ssl=False, verify_ssl=False, timeout=None, retries=3, use_udp=False, udp_port=4444, proxies=None, pool_size=10, path='', cert=None, gzip=False, session=None, headers=None, ):
Since internally, you are essentially building a URL:
https://github.com/influxdata/influxdb-python/blob/c3903dda515d4f7efcb8c55250fd8b75c8446034/influxdb/client.py#L166
You should provide an url argument, that would take precedence over host, port, ...
url
host
port
To not break API compatibility, you could do it this way:
def __init__(self, url=None, host='localhost', port=8086, username='root', password='root', … if url: self.__baseurl = url else: # current logic self.__baseurl = "{0}://{1}:{2}{3}".format( self._scheme, self._host, self._port, self._path)
I think InfluxDBClient.from_dsn() meets your needs: https://github.com/influxdata/influxdb-python/blob/2c3d49cb51fd37db494a7785fe645e24f277854c/influxdb/client.py#L221-L259
InfluxDBClient.from_dsn()
It is now very convenient to configure a Influx client with a server url. Most Influx client libraries support that.
At the moment, the client API is that:
Since internally, you are essentially building a URL:
https://github.com/influxdata/influxdb-python/blob/c3903dda515d4f7efcb8c55250fd8b75c8446034/influxdb/client.py#L166
You should provide an
url
argument, that would take precedence overhost
,port
, ...To not break API compatibility, you could do it this way: