Browse Source

Document previously undocmented control commands

Ask Solem 13 years ago
parent
commit
e4db3e1e22
3 changed files with 102 additions and 23 deletions
  1. 21 21
      celery/tests/app/test_control.py
  2. 2 2
      celery/tests/worker/test_control.py
  3. 79 0
      docs/whatsnew-2.6.rst

+ 21 - 21
celery/tests/app/test_control.py

@@ -92,35 +92,15 @@ class test_inspect(Case):
         self.assertIn("dump_revoked", MockMailbox.sent)
 
     @with_mock_broadcast
-    def test_asks(self):
+    def test_tasks(self):
         self.i.registered()
         self.assertIn("dump_tasks", MockMailbox.sent)
 
-    @with_mock_broadcast
-    def test_enable_events(self):
-        self.i.enable_events()
-        self.assertIn("enable_events", MockMailbox.sent)
-
-    @with_mock_broadcast
-    def test_disable_events(self):
-        self.i.disable_events()
-        self.assertIn("disable_events", MockMailbox.sent)
-
     @with_mock_broadcast
     def test_ping(self):
         self.i.ping()
         self.assertIn("ping", MockMailbox.sent)
 
-    @with_mock_broadcast
-    def test_add_consumer(self):
-        self.i.add_consumer("foo")
-        self.assertIn("add_consumer", MockMailbox.sent)
-
-    @with_mock_broadcast
-    def test_cancel_consumer(self):
-        self.i.cancel_consumer("foo")
-        self.assertIn("cancel_consumer", MockMailbox.sent)
-
     @with_mock_broadcast
     def test_active_queues(self):
         self.i.active_queues()
@@ -172,6 +152,26 @@ class test_Broadcast(Case):
         self.control.time_limit(mytask.name, soft=10, hard=20)
         self.assertIn("time_limit", MockMailbox.sent)
 
+    @with_mock_broadcast
+    def test_add_consumer(self):
+        self.control.add_consumer("foo")
+        self.assertIn("add_consumer", MockMailbox.sent)
+
+    @with_mock_broadcast
+    def test_cancel_consumer(self):
+        self.control.cancel_consumer("foo")
+        self.assertIn("cancel_consumer", MockMailbox.sent)
+
+    @with_mock_broadcast
+    def test_enable_events(self):
+        self.control.enable_events()
+        self.assertIn("enable_events", MockMailbox.sent)
+
+    @with_mock_broadcast
+    def test_disable_events(self):
+        self.control.disable_events()
+        self.assertIn("disable_events", MockMailbox.sent)
+
     @with_mock_broadcast
     def test_revoke(self):
         self.control.revoke("foozbaaz")

+ 2 - 2
celery/tests/worker/test_control.py

@@ -204,8 +204,8 @@ class test_ControlPanel(Case):
             cancelled = []
             consuming = False
 
-            def add_consumer_from_dict(self, **declaration):
-                self.queues.append(declaration["queue"])
+            def add_queue(self, queue):
+                self.queues.append(queue.name)
 
             def consume(self):
                 self.consuming = True

+ 79 - 0
docs/whatsnew-2.6.rst

@@ -30,6 +30,7 @@ as well as PyPy and Jython.
 
 .. contents::
     :local:
+    :depth: 1
 
 .. _v260-important:
 
@@ -266,6 +267,73 @@ Tasks can now have callbacks and errbacks, and dependencies are recorded
                     tasks.add(8, 8),
                     tasks.add(9, 9)]) | tasks.pow(2)
 
+Additional control commands made public
+---------------------------------------
+
+- ``add_consumer``/``cancel_consumer``
+
+    Tells workers to consume from a new queue, or cancel consuming from a
+    queue.  This command has also been changed so that the worker remembers
+    the queues added, so that the change will persist even if
+    the connection is re-connected.
+
+    These commands are available programmatically as
+    :meth:`@control.add_consumer` / :meth:`@control.cancel_consumer`:
+
+    .. code-block::
+
+        >>> celery.control.add_consumer(queue_name,
+        ...     destination=["w1.example.com"])
+        >>> celery.control.cancel_consumer(queue_name,
+        ...     destination=["w1.example.com"])
+
+    or using the :program:`celery control` command::
+
+        $ celery control -d w1.example.com add_consumer queue
+        $ celery control -d w1.example.com cancel_consumer queue
+
+    .. note::
+
+        Remember that a control command without *destination* will be
+        sent to **all workers**.
+
+- ``autoscale``
+
+    Tells workers with `--autoscale` enabled to change autoscale
+    max/min concurrency settings.
+
+    This command is available programmatically as :meth:`@control.autoscale`:
+
+    .. code-block::
+
+        >>> celery.control.autoscale(max=10, min=5,
+        ...     destination=["w1.example.com"])
+
+    or using the :program:`celery control` command::
+
+        $ celery control -d w1.example.com autoscale 10 5
+
+- ``pool_grow``/``pool_shrink``
+
+    Tells workers to add or remove pool processes.
+
+    These commands are available programmatically as
+    :meth:`@control.pool_grow` / :meth:`@control.pool_shrink`:
+
+    .. code-block::
+
+        >>> celery.control.pool_grow(2, destination=["w1.example.com"])
+        >>> celery.contorl.pool_shrink(2, destination=["w1.example.com"])
+
+    or using the :program:`celery control` command::
+
+        $ celery control -d w1.example.com pool_grow 2
+        $ celery control -d w1.example.com pool_shrink 2
+
+- :program:`celery control` now supports ``rate_limit`` & ``time_limit``
+  commands.
+
+    See ``celery control --help`` for details.
 
 Crontab now supports Day of Month, and Month of Year arguments
 --------------------------------------------------------------
@@ -665,6 +733,17 @@ Deprecations
 
 See the :ref:`deprecation-timeline`.
 
+The following undocumented API's has been moved:
+
+- ``control.inspect.add_consumer`` -> :meth:`@control.add_consumer`.
+- ``control.inspect.cancel_consumer`` -> :meth:`@control.cancel_consumer`.
+- ``control.inspect.enable_events`` -> :meth:`@control.enable_events`.
+- ``control.inspect.disable_events`` -> :meth:`@control.disable_events`.
+
+This way ``inspect()`` is only used for commands that do not
+modify anything, while idempotent control commands that make changes
+are on the control objects.
+
 Fixes
 =====