SRV record resolver for python
Project description
SRV resolver
Helper to get record from SRV address according to RFC2782.
Features
- support of record weights and priorities
- check service availability at specific port
- random record selector
- cache with ttl support
Install
The package can be installed simply by using pip
:
pip install srvresolver
Example
from srvresolver.srv_resolver import SRVResolver
# get all records
SRVResolver.resolve('_service._tcp.example.com')
# get one random record with working connection
SRVResolver.resolve_random('_service._tcp.example.com')
# get first available server
SRVResolver.resolve_first('_service._tcp.example.com')
Adds
Resolver with DNS cache
This one uses cache implemented in dnspython module.
from srvresolver.srv_resolver_cached import SRVResolverCached
# get all records
SRVResolverCached.resolve('_service._tcp.example.com')
# same but don't do dns request, load from cache if not expired
SRVResolverCached.resolve('_service._tcp.example.com')
Postgres SRV record resolver
Extract postgres records from SRV and check whether master or slave. Requires psycopg2
from srvresolver.postgres_resolver import PostgresResolver
# get random working slave record
PostgresResolver.get_slave('_postgresql._tcp.example.com', username, password)
# get random working master record
PostgresResolver.get_master('_postgresql._tcp.example.com', username, password)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
srvresolver-0.3.5.tar.gz
(5.4 kB
view hashes)
Built Distribution
Close
Hashes for srvresolver-0.3.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cbb756d929b267e03dac98ea6d9a188d5ce6c8d30ca5553ed6737fb5ddd1c09 |
|
MD5 | f3e38c86c877bd41f7fff0890d6b766f |
|
BLAKE2b-256 | 688b4b709c286edcce48fca1c003cff66f2a8b34c6fda0c580611544f3afe814 |