From b729161d85923fce28a353f608eb065c91b4c034 Mon Sep 17 00:00:00 2001
From: Joshua Harlow <jxharlow@godaddy.com>
Date: Mon, 16 May 2016 15:25:55 -0700
Subject: [PATCH] Move over pull request from github #8 to here

See: https://github.com/vilobhmm/delimiter/pull/8/

Change-Id: I7d8b49426009a023b8ed2b0359f6ffdbc1ef738e
---
 delimiter/drivers/zookeeper.py                       |  4 ++--
 delimiter/processors/__init__.py                     |  0
 .../{processors.py => processors/upper_bound.py}     | 12 ++----------
 3 files changed, 4 insertions(+), 12 deletions(-)
 create mode 100644 delimiter/processors/__init__.py
 rename delimiter/{processors.py => processors/upper_bound.py} (78%)

diff --git a/delimiter/drivers/zookeeper.py b/delimiter/drivers/zookeeper.py
index df2a5c0..6c5e399 100644
--- a/delimiter/drivers/zookeeper.py
+++ b/delimiter/drivers/zookeeper.py
@@ -21,7 +21,7 @@ from kazoo.protocol import paths
 
 from delimiter import engine
 from delimiter import exceptions
-from delimiter import processors
+from delimiter.processors import upper_bound
 
 
 class ZookeeperQuotaEngine(engine.QuotaEngine):
@@ -34,7 +34,7 @@ class ZookeeperQuotaEngine(engine.QuotaEngine):
 
     #: Limit processors that this engine supports.
     processors = {
-        'upper_bound': processors.UpperBoundProcessor(),
+        'upper_bound': upper_bound.UpperBoundProcessor(),
     }
 
     def __init__(self, uri):
diff --git a/delimiter/processors/__init__.py b/delimiter/processors/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/delimiter/processors.py b/delimiter/processors/upper_bound.py
similarity index 78%
rename from delimiter/processors.py
rename to delimiter/processors/upper_bound.py
index bc4521c..4849347 100644
--- a/delimiter/processors.py
+++ b/delimiter/processors/upper_bound.py
@@ -16,18 +16,17 @@
 import collections
 
 from delimiter import exceptions
-
+from delimiter import processor
 
 BoundedResource = collections.namedtuple('BoundedResource',
                                          ['consumed', 'bound'])
 
 
-class UpperBoundProcessor(object):
+class UpperBoundProcessor(processor.Processor):
     """Processes a limit given some upper bound."""
 
     @staticmethod
     def create(limit):
-        """Given some limit, turn it into a *internal* details dict."""
         return {
             'consumed': 0,
             'bound': limit,
@@ -35,23 +34,16 @@ class UpperBoundProcessor(object):
 
     @staticmethod
     def decode(details):
-        """Turn a internal details dict into a user-viewable one."""
         return BoundedResource(details['consumed'], details['bound'])
 
     @staticmethod
     def update(details, limit):
-        """Given internal details dict update it with the given limit."""
         details = details.copy()
         details['bound'] = limit
         return details
 
     @staticmethod
     def process(details, amount):
-        """Given internal details dict process the amount given (or die).
-
-        Updates (and returns) the internal details dict if
-        successful (otherwise raises some exception).
-        """
         consumed = details['consumed']
         if consumed + amount > details['bound']:
             raise exceptions.OverLimitException(