Permalink
Browse files

Rename ndServiceRegistry to nd_service_registry to conform with Googl…

…e Python Guidelines.
  • Loading branch information...
diranged committed Jan 2, 2013
1 parent ca72b3f commit 78a3faaaed8903a1c7ea30dc3d0a70a2c2a94dbf
View
@@ -1,8 +1,8 @@
=================
ndServiceRegistry
=================
===================
nd_service_registry
===================
*`ndServiceRegistry`* is a Python module that provides a simple way to leverage
*`nd_service_registry`* is a Python module that provides a simple way to leverage
*`Apache Zookeeper`* as a dynamic configuration and service registry.
The goal of the package is to provide a single foundational class that can be
@@ -28,7 +28,7 @@ To install, run ::
or ::
pip install ndServiceRegistry
pip install nd_service_registry
Instantiating a KazooServiceRegistry module
-------------------------------------------
@@ -43,10 +43,10 @@ Create a logger object::
To create your initial connection object::
>>> from ndServiceRegistry import KazooServiceRegistry
>>> from nd_service_registry import KazooServiceRegistry
>>> nd = KazooServiceRegistry()
The KazooServiceRegistry object is a child of ndServiceRegistry that conforms
The KazooServiceRegistry object is a child of nd_service_registry that conforms
to our ServiceRegistry specs, whlie leveraging Kazoo as the backend. The
object handles all of your connection states - there is no need to start/stop
or monitor the connection state at all.
@@ -83,7 +83,7 @@ can though, we instead just *return False* as a way of indicating that we were
unable to perform your command now ... but that we will take care of it later.
Whenever we do this, we throw a WARNING log message as well.
ndServiceRegistry.exceptions.NoConnection
nd_service_registry.exceptions.NoConnection
Thrown if you attempt any operation that requires immediate access to the
backend Zookeeper service. Either a *set()* operation, or a *get()*
operation on a path for the first time.
@@ -94,7 +94,7 @@ ndServiceRegistry.exceptions.NoConnection
if Zookeeper is down. This allows the service to fail temporarily in the
background but your app is still able to get the 'last known' results.)
ndServiceRegistry.exceptions.ReadOnly
nd_service_registry.exceptions.ReadOnly
If *readonly=True*, any operation that would result in a 'write' will throw
this exception. Most notably, a *set()* operation will fail with this
exception if *readonly=True*.
@@ -14,12 +14,12 @@
"""Simple service registration class for managing lists of servers.
The ndServiceRegistry model at Nextdoor is geared around simplicity and
The nd_service_registry model at Nextdoor is geared around simplicity and
reliability. This model provides a few core features that allow you to
register and unregister nodes that provide certain services, and to monitor
particular service paths for lists of nodes.
Although the service structure is up to you, the ndServiceRegistry model is
Although the service structure is up to you, the nd_service_registry model is
largely designed around this model:
/production
@@ -37,7 +37,7 @@
Example usage to provide the above service list:
>>> from ndServiceRegistry import KazooServiceRegistry
>>> from nd_service_registry import KazooServiceRegistry
>>> nd = KazooServiceRegistry()
>>> nd.set_node('/production/ssh/server1:22')
>>> nd.set_node('/production/ssh/server2:22')
@@ -61,7 +61,7 @@
aversion=0, ephemeralOwner=0, dataLength=0,
numChildren=3, pzxid=45)}
When you call get(), the ndServiceRegistry module goes out and creates a
When you call get(), the nd_service_registry module goes out and creates a
Watcher object for the path you provided. This object caches all of the state
data for the supplied path in a local dict. This dict is updated any time the
Zookeeper service sees a change to that path.
@@ -90,23 +90,23 @@
__author__ = 'matt@nextdoor.com (Matt Wise)'
# For ndServiceRegistry Class
# For nd_service_registry Class
import os
import logging
import exceptions
from os.path import split
from functools import wraps
# Our own classes
from ndServiceRegistry.registration import EphemeralNode
from ndServiceRegistry.watcher import Watcher
from ndServiceRegistry.watcher import DummyWatcher
from ndServiceRegistry import funcs
from ndServiceRegistry import exceptions
from nd_service_registry.registration import EphemeralNode
from nd_service_registry.watcher import Watcher
from nd_service_registry.watcher import DummyWatcher
from nd_service_registry import funcs
from nd_service_registry import exceptions
# For KazooServiceRegistry Class
import kazoo.security
from ndServiceRegistry.shims import ZookeeperClient
from nd_service_registry.shims import ZookeeperClient
from kazoo.client import KazooState
# Use Gevent as our threader (DOES NOT WORK RIGHT NOW)
@@ -125,7 +125,7 @@
SERVER = 'localhost:2181'
class ndServiceRegistry(object):
class nd_service_registry(object):
"""Main Service Registry object.
The ServiceRegistry object is a framework object, not meant to be
@@ -302,11 +302,11 @@ def _convert_dummywatchers_to_watchers(self):
self._watchers[path] = w
class KazooServiceRegistry(ndServiceRegistry):
class KazooServiceRegistry(nd_service_registry):
_instance = None
_initialized = False
LOGGER = 'ndServiceRegistry.KazooServiceRegistry'
LOGGER = 'nd_service_registry.KazooServiceRegistry'
def __new__(self, **kwargs):
"""Only creates a new object if one does not already exist."""
@@ -673,7 +673,7 @@ def get(self, path, callback=None):
changes.
Returns:
ndServiceRegistry.Watcher.get() dict object
nd_service_registry.Watcher.get() dict object
"""
# Return the object from our cache, if it's there
@@ -707,7 +707,6 @@ def get(self, path, callback=None):
'try again later: %s' % (path, e))
return False
@_health_check
def _get_watcher(self, path, callback=None):
"""Creates a Watcher object for the supplid path.
@@ -725,7 +724,7 @@ def _get_watcher(self, path, callback=None):
changes.
Returns:
ndServiceRegistry.Watcher object
nd_service_registry.Watcher object
"""
# Ok, so the cache is missing the key. Lets look for it in Zookeeper
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Exceptions for ndServiceRegistry
"""Exceptions for nd_service_registry
Copyright 2012 Nextdoor Inc."""
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Commonly used functions for ndServiceRegistry
"""Commonly used functions for nd_service_registry
Copyright 2012 Nextdoor Inc."""
@@ -27,7 +27,7 @@
from functools import wraps
# logger name
LOGGER = 'ndServiceRegistry.funcs'
LOGGER = 'nd_service_registry.funcs'
def encode(data=None):
@@ -56,8 +56,8 @@
import time
import sys
from ndServiceRegistry import funcs
from ndServiceRegistry.watcher import Watcher
from nd_service_registry import funcs
from nd_service_registry.watcher import Watcher
# For KazooServiceRegistry Class
import kazoo.exceptions
@@ -71,7 +71,7 @@
class Registration(object):
"""An object that registers a znode with ZooKeeper."""
LOGGING = 'ndServiceRegistry.Registration'
LOGGING = 'nd_service_registry.Registration'
def __init__(self, zk, path, data=None, state=True):
# Create our logger
@@ -242,7 +242,7 @@ class EphemeralNode(Registration):
The node registered with Zookeeper is ephemeral, so if we lose our
connection to the service, we have to re-register the data."""
LOGGING = 'ndServiceRegistry.Registration.EphemeralNode'
LOGGING = 'nd_service_registry.Registration.EphemeralNode'
def __init__(self, zk, path, data, state=True):
"""Sets the ZooKeeper registration up to be ephemeral.
@@ -12,15 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""ndServiceRegistry Zookeeper Client Library
"""nd_service_registry Zookeeper Client Library
Copyright 2012 Nextdoor Inc."""
__author__ = 'matt@nextdoor.com (Matt Wise)'
import logging
from kazoo.client import KazooClient
from ndServiceRegistry.funcs import rate_limiter
from nd_service_registry.funcs import rate_limiter
# Our default variables
from version import __version__ as VERSION
@@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
__version__ = '0.1.1' # http://semver.org/
__version__ = '0.2.0' # http://semver.org/
@@ -24,7 +24,7 @@
import sys
from os.path import split
from ndServiceRegistry import funcs
from nd_service_registry import funcs
# For KazooServiceRegistry Class
import kazoo.exceptions
@@ -59,7 +59,7 @@ class Watcher(object):
}
"""
LOGGING = 'ndServiceRegistry.Watcher'
LOGGING = 'nd_service_registry.Watcher'
def __init__(self, zk, path, callback=None, watch_children=True):
# Create our logger
@@ -194,7 +194,7 @@ class DummyWatcher(Watcher):
want to be able to return valid data.
"""
LOGGING = 'ndServiceRegistry.DummyWatcher'
LOGGING = 'nd_service_registry.DummyWatcher'
def __init__(self, path, data, callback=None):
# Create our logger
View
@@ -20,7 +20,7 @@
from distutils.command.sdist import sdist
from setuptools import setup
PACKAGE = 'ndServiceRegistry'
PACKAGE = 'nd_service_registry'
__version__ = None
execfile(os.path.join(PACKAGE, 'version.py')) # set __version__
@@ -46,19 +46,19 @@ def maybe_rm(path):
if os.path.exists(path):
shutil.rmtree(path)
if self.all:
maybe_rm('ndServiceRegistry.egg-info')
maybe_rm('nd_service_registry.egg-info')
maybe_rm('dist')
setup(
name='ndServiceRegistry',
name='nd_service_registry',
version=__version__,
description='Nextdoor ServiceRegistry module for interacting with Apache Zookeeper.',
long_description=open('README.rst').read(),
author='Matt Wise',
author_email='matt@nextdoor.com',
url='https://github.com/Nextdoor/ndServiceRegistry',
download_url='http://pypi.python.org/pypi/ndServiceRegistry#downloads',
url='https://github.com/Nextdoor/ndserviceregistry',
download_url='http://pypi.python.org/pypi/nd_service_registry#downloads',
license='Apache License, Version 2.0',
keywords='zookeeper apache zk',
packages=[PACKAGE],

0 comments on commit 78a3faa

Please sign in to comment.