From 0c945134540f09d64f68881ef1485e1ac7994962 Mon Sep 17 00:00:00 2001 From: Fabio Cerqueira Date: Sat, 6 Jan 2018 18:22:08 +0000 Subject: [PATCH] Rename DNS to DSN(Data source name) #306 --- docs/apps/data/clients.rst | 4 ++-- docs/spelling_wordlist.txt | 1 + pulsar/apps/data/channels.py | 6 +++--- pulsar/apps/data/pulsards/startds.py | 6 +++--- pulsar/apps/data/redis/store.py | 2 +- pulsar/apps/data/store.py | 16 ++++++++-------- tests/stores/channels.py | 2 +- tests/stores/test_pulsards.py | 4 ++-- 8 files changed, 21 insertions(+), 20 deletions(-) diff --git a/docs/apps/data/clients.rst b/docs/apps/data/clients.rst index 79949a58..58ee62d0 100644 --- a/docs/apps/data/clients.rst +++ b/docs/apps/data/clients.rst @@ -18,7 +18,7 @@ function with a valid :ref:`connection string `:: 'redis' >>> store.database '11' - >>> store.dns + >>> store.dsn 'redis://user:password@127.0.0.1:6500/11' Additional parameters can be passed via the connection string or as key-valued @@ -26,7 +26,7 @@ parameters. For example:: >>> store = create_store('redis://user:password@127.0.0.1:6500/11', namespace='test_') - >>> store.dns + >>> store.dsn 'redis://user:password@127.0.0.1:6500/11?namespace=test_' diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index 2a78b50b..0c79ff11 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -45,6 +45,7 @@ dev django Django dns +dsn ds eg epilog diff --git a/pulsar/apps/data/channels.py b/pulsar/apps/data/channels.py index 837b5284..26e9a79b 100644 --- a/pulsar/apps/data/channels.py +++ b/pulsar/apps/data/channels.py @@ -71,10 +71,10 @@ def __init__(self, store, namespace=None): self.namespace = '%s%s' % ( self.namespace, self.namespace_delimiter ) - self.dns = store.buildurl(namespace=self.namespace) + self.dsn = store.buildurl(namespace=self.namespace) def __repr__(self): - return self.dns + return self.dsn def __str__(self): return self.__repr__() @@ -114,7 +114,7 @@ def _loop(self): return self.store._loop def __repr__(self): - return self.dns + return self.dsn def __len__(self): return len(self.channels) diff --git a/pulsar/apps/data/pulsards/startds.py b/pulsar/apps/data/pulsards/startds.py index 0f903459..44b7022c 100644 --- a/pulsar/apps/data/pulsards/startds.py +++ b/pulsar/apps/data/pulsards/startds.py @@ -40,9 +40,9 @@ async def start_store(app, url, workers=0, **kw): cfg = await send('arbiter', 'run', start_pulsar_ds, host, workers) store._host = cfg.addresses[0] - dns = store.buildurl() - store = create_store(dns, **kw) - app.cfg.set('data_store', store.dns) + dsn = store.buildurl() + store = create_store(dsn, **kw) + app.cfg.set('data_store', store.dsn) def localhost(host): diff --git a/pulsar/apps/data/redis/store.py b/pulsar/apps/data/redis/store.py index 85893ee3..ac260c62 100644 --- a/pulsar/apps/data/redis/store.py +++ b/pulsar/apps/data/redis/store.py @@ -37,7 +37,7 @@ def namespace(self): return '%s:' % n if n else '' def key(self): - return (self._dns, self._encoding) + return (self._dsn, self._encoding) def client(self): '''Get a :class:`.RedisClient` for the Store''' diff --git a/pulsar/apps/data/store.py b/pulsar/apps/data/store.py index ec00a366..2e0525a4 100644 --- a/pulsar/apps/data/store.py +++ b/pulsar/apps/data/store.py @@ -79,7 +79,7 @@ def __init__(self, host=None, database=None, self._password = password self._urlparams = {} self._init(**kw) - self._dns = self.buildurl() + self._dsn = self.buildurl() @property def database(self): @@ -89,7 +89,7 @@ def database(self): @database.setter def database(self, value): self._database = value - self._dns = self.buildurl() + self._dsn = self.buildurl() @property def encoding(self): @@ -98,13 +98,13 @@ def encoding(self): return self._encoding @property - def dns(self): - '''Domain name server''' - return self._dns + def dsn(self): + '''Data source name''' + return self._dsn @property def urlparams(self): - """url parameters in dns query""" + """url parameters in dsn query""" return self._urlparams @classmethod @@ -112,10 +112,10 @@ def register(cls): pass def __str__(self): - return self._dns + return self._dsn def __repr__(self): - return 'Store(dns="%s")' % self + return 'Store(dsn="%s")' % self def database_create(self, dbname=None, **kw): '''Create a new database in this store. diff --git a/tests/stores/channels.py b/tests/stores/channels.py index 3f4a9b23..da3fc072 100644 --- a/tests/stores/channels.py +++ b/tests/stores/channels.py @@ -21,7 +21,7 @@ def channels(self, **kw): kw['protocol'] = Json() return self.store.channels(**kw) - def test_channels_dns(self): + def test_channels_dsn(self): channels = self.channels() self.assertEqual(channels.namespace, '%s_' % self.namespace()) channels = self.channels(namespace='foo') diff --git a/tests/stores/test_pulsards.py b/tests/stores/test_pulsards.py index 98dd3cdf..71880f2c 100644 --- a/tests/stores/test_pulsards.py +++ b/tests/stores/test_pulsards.py @@ -161,7 +161,7 @@ async def test_move(self): eq(await c.move(key, db), False) eq(await c.set(key, 'ciao'), True) eq(await c.move(key, db), True) - s2 = self.create_store(self.store.dns, database=db) + s2 = self.create_store(self.store.dsn, database=db) c2 = s2.client() eq(await c2.get(key), b'ciao') eq(await c.exists(key), False) @@ -1267,6 +1267,6 @@ def test_store_methods(self): self.assertEqual(store.database, 8) store.database = 10 self.assertEqual(store.database, 10) - self.assertTrue(store.dns.startswith('%s/10?' % self.pulsards_uri)) + self.assertTrue(store.dsn.startswith('%s/10?' % self.pulsards_uri)) self.assertEqual(store.encoding, 'utf-8') self.assertTrue(repr(store))