Skip to content

Commit 7c402fa

Browse files
committed
Show deprecation warnings for old configuration options.
1 parent f46e24e commit 7c402fa

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

typesense/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
from .client import Client # NOQA
1+
from .client import Client # NOQA
2+
import logging
3+
4+
logging.basicConfig(level=logging.WARN)

typesense/configuration.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
import logging
2+
13
from .exceptions import ConfigError
24

5+
logger = logging.getLogger(__name__)
6+
37

48
class Node(object):
59
def __init__(self, host, port, path, protocol):
@@ -17,6 +21,7 @@ def url(self):
1721

1822
class Configuration(object):
1923
def __init__(self, config_dict):
24+
Configuration.show_deprecation_warnings(config_dict)
2025
Configuration.validate_config_dict(config_dict)
2126

2227
node_dicts = config_dict.get('nodes', [])
@@ -59,3 +64,15 @@ def validate_config_dict(config_dict):
5964
def validate_node_fields(node):
6065
expected_fields = {'host', 'port', 'protocol'}
6166
return expected_fields.issubset(node)
67+
68+
@staticmethod
69+
def show_deprecation_warnings(config_dict):
70+
if config_dict.get('timeout_seconds'):
71+
logger.warn('Deprecation warning: timeout_seconds is now renamed to connection_timeout_seconds')
72+
73+
if config_dict.get('master_node'):
74+
logger.warn('Deprecation warning: master_node is now consolidated to nodes, starting with Typesense Server v0.12')
75+
76+
if config_dict.get('read_replica_nodes'):
77+
logger.warn('Deprecation warning: read_replica_nodes is now consolidated to nodes, starting with Typesense Server v0.12')
78+

0 commit comments

Comments
 (0)