diff options
Diffstat (limited to 'utils/classes.html')
| -rw-r--r-- | utils/classes.html | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/utils/classes.html b/utils/classes.html index 4730048..af14fda 100644 --- a/utils/classes.html +++ b/utils/classes.html | |||
| @@ -84,6 +84,7 @@ | |||
| 84 | 84 | ||
| 85 | <ul class="current"> | 85 | <ul class="current"> |
| 86 | <li class="toctree-l1 current"><a class="reference internal" href="../api.html">API Documentation</a><ul class="current"> | 86 | <li class="toctree-l1 current"><a class="reference internal" href="../api.html">API Documentation</a><ul class="current"> |
| 87 | <li class="toctree-l2"><a class="reference internal" href="../client.html"><code class="docutils literal"><span class="pre">client</span></code> – Client Utilities</a></li> | ||
| 87 | <li class="toctree-l2"><a class="reference internal" href="../exceptions.html"><code class="docutils literal"><span class="pre">exceptions</span></code> – Exceptions</a></li> | 88 | <li class="toctree-l2"><a class="reference internal" href="../exceptions.html"><code class="docutils literal"><span class="pre">exceptions</span></code> – Exceptions</a></li> |
| 88 | <li class="toctree-l2"><a class="reference internal" href="../jobmanager.html"><code class="docutils literal"><span class="pre">jobmanager</span></code> – Job Manager</a></li> | 89 | <li class="toctree-l2"><a class="reference internal" href="../jobmanager.html"><code class="docutils literal"><span class="pre">jobmanager</span></code> – Job Manager</a></li> |
| 89 | <li class="toctree-l2"><a class="reference internal" href="../poller.html"><code class="docutils literal"><span class="pre">poller</span></code> – Poller</a></li> | 90 | <li class="toctree-l2"><a class="reference internal" href="../poller.html"><code class="docutils literal"><span class="pre">poller</span></code> – Poller</a></li> |
| @@ -151,6 +152,117 @@ | |||
| 151 | <h1><code class="xref py py-mod docutils literal"><span class="pre">classes</span></code> – Utility Classes<a class="headerlink" href="#classes-utility-classes" title="Permalink to this headline">¶</a></h1> | 152 | <h1><code class="xref py py-mod docutils literal"><span class="pre">classes</span></code> – Utility Classes<a class="headerlink" href="#classes-utility-classes" title="Permalink to this headline">¶</a></h1> |
| 152 | <p>Defines some classes to use when implementing ZMQ devices</p> | 153 | <p>Defines some classes to use when implementing ZMQ devices</p> |
| 153 | <dl class="class"> | 154 | <dl class="class"> |
| 155 | <dt id="eventmq.utils.classes.EMQPService"> | ||
| 156 | <em class="property">class </em><code class="descclassname">eventmq.utils.classes.</code><code class="descname">EMQPService</code><a class="headerlink" href="#eventmq.utils.classes.EMQPService" title="Permalink to this definition">¶</a></dt> | ||
| 157 | <dd><p>Helper for devices that connect to brokers.</p> | ||
| 158 | <p>Implements utility methods for sending EMQP messages for the following | ||
| 159 | EMQP commands.</p> | ||
| 160 | <blockquote> | ||
| 161 | <div><ul class="simple"> | ||
| 162 | <li>INFORM</li> | ||
| 163 | </ul> | ||
| 164 | </div></blockquote> | ||
| 165 | <p>Also implements utlitiy methods for managing long-running processes.</p> | ||
| 166 | <dl class="docutils"> | ||
| 167 | <dt>To use you must define:</dt> | ||
| 168 | <dd><ul class="first last simple"> | ||
| 169 | <li><cite>self.outgoing</cite> - socket where messages can be sent to the Router</li> | ||
| 170 | <li><cite>self.SERVICE_TYPE</cite> - defines the service type for INFORM. See | ||
| 171 | <a class="reference internal" href="#eventmq.utils.classes.EMQPService.send_inform" title="eventmq.utils.classes.EMQPService.send_inform"><code class="xref py py-meth docutils literal"><span class="pre">send_inform()</span></code></a> for more information.</li> | ||
| 172 | <li><cite>self.poller</cite> - the poller that <cite>self.outgoing</cite> will be using. | ||
| 173 | Usually: <cite>self.poller = eventmq.poller.Poller()</cite></li> | ||
| 174 | </ul> | ||
| 175 | </dd> | ||
| 176 | </dl> | ||
| 177 | <p>When messages are received from the router, they are processed in | ||
| 178 | <a class="reference internal" href="#eventmq.utils.classes.EMQPService.process_message" title="eventmq.utils.classes.EMQPService.process_message"><code class="xref py py-meth docutils literal"><span class="pre">process_message()</span></code></a> which then calls <cite>on_COMMAND</cite>. This should be used | ||
| 179 | in the event loop so if you want to respond to the SCHEDULE command, you | ||
| 180 | would define the method <cite>on_schedule</cite> in your service class.</p> | ||
| 181 | <p>See the code for <code class="xref py py-class docutils literal"><span class="pre">Scheduler</span></code> and <code class="xref py py-class docutils literal"><span class="pre">JobManager</span></code> for examples.</p> | ||
| 182 | <dl class="attribute"> | ||
| 183 | <dt id="eventmq.utils.classes.EMQPService.__weakref__"> | ||
| 184 | <code class="descname">__weakref__</code><a class="headerlink" href="#eventmq.utils.classes.EMQPService.__weakref__" title="Permalink to this definition">¶</a></dt> | ||
| 185 | <dd><p>list of weak references to the object (if defined)</p> | ||
| 186 | </dd></dl> | ||
| 187 | |||
| 188 | <dl class="attribute"> | ||
| 189 | <dt id="eventmq.utils.classes.EMQPService.is_heartbeat_enabled"> | ||
| 190 | <code class="descname">is_heartbeat_enabled</code><a class="headerlink" href="#eventmq.utils.classes.EMQPService.is_heartbeat_enabled" title="Permalink to this definition">¶</a></dt> | ||
| 191 | <dd><p>Property to check if heartbeating is enabled. Useful when certain | ||
| 192 | properties must be updated for heartbeating | ||
| 193 | :returns: bool - True if heartbeating is enabled, False if it isn’t</p> | ||
| 194 | </dd></dl> | ||
| 195 | |||
| 196 | <dl class="method"> | ||
| 197 | <dt id="eventmq.utils.classes.EMQPService.on_ack"> | ||
| 198 | <code class="descname">on_ack</code><span class="sig-paren">(</span><em>msgid</em>, <em>ackd_msgid</em><span class="sig-paren">)</span><a class="headerlink" href="#eventmq.utils.classes.EMQPService.on_ack" title="Permalink to this definition">¶</a></dt> | ||
| 199 | <dd><p>Sets <code class="xref py py-attr docutils literal"><span class="pre">awaiting_ack</span></code> to False</p> | ||
| 200 | </dd></dl> | ||
| 201 | |||
| 202 | <dl class="method"> | ||
| 203 | <dt id="eventmq.utils.classes.EMQPService.process_message"> | ||
| 204 | <code class="descname">process_message</code><span class="sig-paren">(</span><em>msg</em><span class="sig-paren">)</span><a class="headerlink" href="#eventmq.utils.classes.EMQPService.process_message" title="Permalink to this definition">¶</a></dt> | ||
| 205 | <dd><p>Processes a message. Processing takes form of calling an | ||
| 206 | <cite>on_EMQP_COMMAND</cite> method. The method must accept <cite>msgid</cite> and <cite>message</cite> | ||
| 207 | as the first arguments.</p> | ||
| 208 | <table class="docutils field-list" frame="void" rules="none"> | ||
| 209 | <col class="field-name" /> | ||
| 210 | <col class="field-body" /> | ||
| 211 | <tbody valign="top"> | ||
| 212 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>msg</strong> – The message received from the socket to parse and process.</td> | ||
| 213 | </tr> | ||
| 214 | </tbody> | ||
| 215 | </table> | ||
| 216 | </dd></dl> | ||
| 217 | |||
| 218 | <dl class="method"> | ||
| 219 | <dt id="eventmq.utils.classes.EMQPService.reset"> | ||
| 220 | <code class="descname">reset</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#eventmq.utils.classes.EMQPService.reset" title="Permalink to this definition">¶</a></dt> | ||
| 221 | <dd><p>Resets the current connection by closing and reopening the socket</p> | ||
| 222 | </dd></dl> | ||
| 223 | |||
| 224 | <dl class="method"> | ||
| 225 | <dt id="eventmq.utils.classes.EMQPService.send_inform"> | ||
| 226 | <code class="descname">send_inform</code><span class="sig-paren">(</span><em>queue=None</em><span class="sig-paren">)</span><a class="headerlink" href="#eventmq.utils.classes.EMQPService.send_inform" title="Permalink to this definition">¶</a></dt> | ||
| 227 | <dd><p>Queues an INFORM command to <cite>self.outgoing</cite>.</p> | ||
| 228 | <table class="docutils field-list" frame="void" rules="none"> | ||
| 229 | <col class="field-name" /> | ||
| 230 | <col class="field-body" /> | ||
| 231 | <tbody valign="top"> | ||
| 232 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> | ||
| 233 | <li><strong>type</strong> (<a class="reference external" href="https://docs.python.org/library/functions.html#str" title="(in Python v2.7)"><em>str</em></a>) – Either ‘worker’ or ‘scheduler’</li> | ||
| 234 | <li><strong>queue</strong> (<a class="reference external" href="https://docs.python.org/library/functions.html#list" title="(in Python v2.7)"><em>list</em></a>) – <ul> | ||
| 235 | <li>For ‘worker’ type, the queues the worker is listening on</li> | ||
| 236 | <li>Ignored for ‘scheduler’ type</li> | ||
| 237 | </ul> | ||
| 238 | </li> | ||
| 239 | </ul> | ||
| 240 | </td> | ||
| 241 | </tr> | ||
| 242 | <tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><p class="first last"><code class="xref py py-exc docutils literal"><span class="pre">ValueError</span></code> – When <cite>type_</cite> does not match a specified type</p> | ||
| 243 | </td> | ||
| 244 | </tr> | ||
| 245 | </tbody> | ||
| 246 | </table> | ||
| 247 | </dd></dl> | ||
| 248 | |||
| 249 | <dl class="method"> | ||
| 250 | <dt id="eventmq.utils.classes.EMQPService.start"> | ||
| 251 | <code class="descname">start</code><span class="sig-paren">(</span><em>addr</em>, <em>queues='default'</em><span class="sig-paren">)</span><a class="headerlink" href="#eventmq.utils.classes.EMQPService.start" title="Permalink to this definition">¶</a></dt> | ||
| 252 | <dd><p>Connect to <cite>addr</cite> and begin listening for job requests</p> | ||
| 253 | <table class="docutils field-list" frame="void" rules="none"> | ||
| 254 | <col class="field-name" /> | ||
| 255 | <col class="field-body" /> | ||
| 256 | <tbody valign="top"> | ||
| 257 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>addr</strong> (<a class="reference external" href="https://docs.python.org/library/functions.html#str" title="(in Python v2.7)"><em>str</em></a>) – connection string to connect to</td> | ||
| 258 | </tr> | ||
| 259 | </tbody> | ||
| 260 | </table> | ||
| 261 | </dd></dl> | ||
| 262 | |||
| 263 | </dd></dl> | ||
| 264 | |||
| 265 | <dl class="class"> | ||
| 154 | <dt id="eventmq.utils.classes.HeartbeatMixin"> | 266 | <dt id="eventmq.utils.classes.HeartbeatMixin"> |
| 155 | <em class="property">class </em><code class="descclassname">eventmq.utils.classes.</code><code class="descname">HeartbeatMixin</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#eventmq.utils.classes.HeartbeatMixin" title="Permalink to this definition">¶</a></dt> | 267 | <em class="property">class </em><code class="descclassname">eventmq.utils.classes.</code><code class="descname">HeartbeatMixin</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#eventmq.utils.classes.HeartbeatMixin" title="Permalink to this definition">¶</a></dt> |
| 156 | <dd><p>Provides methods for implementing heartbeats</p> | 268 | <dd><p>Provides methods for implementing heartbeats</p> |