Skip to content

Commit

Permalink
Setup heartbeat for server's health check
Browse files Browse the repository at this point in the history
Clean up and update README.md
  • Loading branch information
dormant-user committed May 10, 2023
1 parent eab9329 commit 39a831d
Show file tree
Hide file tree
Showing 15 changed files with 223 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if __name__ == '__main__':
- **TOKEN**: Authentication token.

### Optional Env Vars
- **HEART_BEAT**: Defaults to `None` - _If # of seconds is set, background health check with the server will be enabled_
- **DEBUG**: Defaults to `False` - _Enable debug level logging_
<br><br>
- **SPEECH_TIMEOUT**: Defaults to `0` for macOS, `10` for Windows - _Timeout for speech synthesis_
Expand Down
7 changes: 7 additions & 0 deletions doc_generator/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ Models
:members:
:undoc-members:

Repeated Timer
==============

.. automodule:: jarvis_ui.modules.timer
:members:
:undoc-members:

Speaker
=======

Expand Down
1 change: 1 addition & 0 deletions docs/README.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ <h2>Mandatory Env Vars<a class="headerlink" href="#mandatory-env-vars" title="Pe
<section id="optional-env-vars">
<h2>Optional Env Vars<a class="headerlink" href="#optional-env-vars" title="Permalink to this heading"></a></h2>
<ul class="simple">
<li><p><strong>HEART_BEAT</strong>: Defaults to <code class="docutils literal notranslate"><span class="pre">None</span></code> - <em>If # of seconds is set, background health check with the server will be enabled</em></p></li>
<li><p><strong>DEBUG</strong>: Defaults to <code class="docutils literal notranslate"><span class="pre">False</span></code> - <em>Enable debug level logging</em>
<br><br></p></li>
<li><p><strong>SPEECH_TIMEOUT</strong>: Defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code> for macOS, <code class="docutils literal notranslate"><span class="pre">10</span></code> for Windows - <em>Timeout for speech synthesis</em>
Expand Down
1 change: 1 addition & 0 deletions docs/_sources/README.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if __name__ == '__main__':
- **TOKEN**: Authentication token.

### Optional Env Vars
- **HEART_BEAT**: Defaults to `None` - _If # of seconds is set, background health check with the server will be enabled_
- **DEBUG**: Defaults to `False` - _Enable debug level logging_
<br><br>
- **SPEECH_TIMEOUT**: Defaults to `0` for macOS, `10` for Windows - _Timeout for speech synthesis_
Expand Down
7 changes: 7 additions & 0 deletions docs/_sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ Models
:members:
:undoc-members:

Repeated Timer
==============

.. automodule:: jarvis_ui.modules.timer
:members:
:undoc-members:

Speaker
=======

Expand Down
34 changes: 32 additions & 2 deletions docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ <h1 id="index">Index</h1>
| <a href="#E"><strong>E</strong></a>
| <a href="#F"><strong>F</strong></a>
| <a href="#G"><strong>G</strong></a>
| <a href="#H"><strong>H</strong></a>
| <a href="#I"><strong>I</strong></a>
| <a href="#J"><strong>J</strong></a>
| <a href="#L"><strong>L</strong></a>
Expand Down Expand Up @@ -92,6 +93,8 @@ <h2 id="B">B</h2>
<h2 id="C">C</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#jarvis_ui.modules.timer.RepeatedTimer.cancel">cancel() (jarvis_ui.modules.timer.RepeatedTimer method)</a>
</li>
<li><a href="index.html#jarvis_ui.modules.peripherals.channel_type">channel_type (in module jarvis_ui.modules.peripherals)</a>
</li>
<li><a href="index.html#jarvis_ui.modules.peripherals.ChannelType">ChannelType (class in jarvis_ui.modules.peripherals)</a>
Expand Down Expand Up @@ -157,6 +160,18 @@ <h2 id="G">G</h2>
</ul></td>
</tr></table>

<h2 id="H">H</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#jarvis_ui.modules.models.EnvConfig.heart_beat">heart_beat (jarvis_ui.modules.models.EnvConfig attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#jarvis_ui.executables.starter.heart_beat">heart_beat() (in module jarvis_ui.executables.starter)</a>
</li>
</ul></td>
</tr></table>

<h2 id="I">I</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
Expand Down Expand Up @@ -237,6 +252,13 @@ <h2 id="J">J</h2>

<ul>
<li><a href="index.html#module-jarvis_ui.modules.peripherals">module</a>
</li>
</ul></li>
<li>
jarvis_ui.modules.timer

<ul>
<li><a href="index.html#module-jarvis_ui.modules.timer">module</a>
</li>
</ul></li>
</ul></td>
Expand Down Expand Up @@ -282,6 +304,8 @@ <h2 id="M">M</h2>
<li><a href="index.html#module-jarvis_ui.modules.logger">jarvis_ui.modules.logger</a>
</li>
<li><a href="index.html#module-jarvis_ui.modules.peripherals">jarvis_ui.modules.peripherals</a>
</li>
<li><a href="index.html#module-jarvis_ui.modules.timer">jarvis_ui.modules.timer</a>
</li>
</ul></li>
</ul></td>
Expand Down Expand Up @@ -336,6 +360,8 @@ <h2 id="R">R</h2>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#jarvis_ui.modules.timer.RepeatedTimer">RepeatedTimer (class in jarvis_ui.modules.timer)</a>
</li>
<li><a href="index.html#jarvis_ui.modules.models.EnvConfig.request_url">request_url (jarvis_ui.modules.models.EnvConfig attribute)</a>
</li>
<li><a href="index.html#jarvis_ui.modules.models.FileIO.restart">restart (jarvis_ui.modules.models.FileIO attribute)</a>
Expand All @@ -358,10 +384,10 @@ <h2 id="S">S</h2>
</ul></li>
<li><a href="index.html#jarvis_ui.modules.models.Settings">Settings (class in jarvis_ui.modules.models)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#jarvis_ui.modules.models.FileIO.shutdown">shutdown (jarvis_ui.modules.models.FileIO attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#jarvis_ui.executables.speaker.speak">speak() (in module jarvis_ui.executables.speaker)</a>
</li>
<li><a href="index.html#jarvis_ui.modules.models.EnvConfig.speech_timeout">speech_timeout (jarvis_ui.modules.models.EnvConfig attribute)</a>
Expand All @@ -372,8 +398,12 @@ <h2 id="S">S</h2>

<ul>
<li><a href="index.html#jarvis_ui.executables.starter.Activator.start">(jarvis_ui.executables.starter.Activator method)</a>
</li>
<li><a href="index.html#jarvis_ui.modules.timer.RepeatedTimer.start">(jarvis_ui.modules.timer.RepeatedTimer method)</a>
</li>
</ul></li>
<li><a href="index.html#jarvis_ui.modules.timer.RepeatedTimer.stop">stop() (jarvis_ui.modules.timer.RepeatedTimer method)</a>
</li>
</ul></td>
</tr></table>

Expand Down
65 changes: 65 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ <h1>Models<a class="headerlink" href="#models" title="Permalink to this heading"
<span class="sig-name descname"><span class="pre">debug</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">bool</span></em><a class="headerlink" href="#jarvis_ui.modules.models.EnvConfig.debug" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="jarvis_ui.modules.models.EnvConfig.heart_beat">
<span class="sig-name descname"><span class="pre">heart_beat</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">int</span></em><a class="headerlink" href="#jarvis_ui.modules.models.EnvConfig.heart_beat" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="jarvis_ui.modules.models.EnvConfig.microphone_index">
<span class="sig-name descname"><span class="pre">microphone_index</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">PositiveInt</span><span class="p"><span class="pre">]</span></span></em><a class="headerlink" href="#jarvis_ui.modules.models.EnvConfig.microphone_index" title="Permalink to this definition"></a></dt>
Expand Down Expand Up @@ -412,6 +417,47 @@ <h1>Models<a class="headerlink" href="#models" title="Permalink to this heading"

</dd></dl>

</section>
<section id="module-jarvis_ui.modules.timer">
<span id="repeated-timer"></span><h1>Repeated Timer<a class="headerlink" href="#module-jarvis_ui.modules.timer" title="Permalink to this heading"></a></h1>
<dl class="py class">
<dt class="sig sig-object py" id="jarvis_ui.modules.timer.RepeatedTimer">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">jarvis_ui.modules.timer.</span></span><span class="sig-name descname"><span class="pre">RepeatedTimer</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">interval</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">function</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Callable</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">args</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">Tuple</span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">kwargs</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">Dict</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#jarvis_ui.modules.timer.RepeatedTimer" title="Permalink to this definition"></a></dt>
<dd><p>Instantiates RepeatedTimer object to kick off the threading.Timer object with custom intervals.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">RepeatedTimer</span>
</pre></div>
</div>
<p>Repeats the <code class="docutils literal notranslate"><span class="pre">Timer</span></code> object from threading.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>interval</strong> – Interval in seconds.</p></li>
<li><p><strong>function</strong> – Function to trigger with intervals.</p></li>
<li><p><strong>args</strong> – Arguments for the function.</p></li>
<li><p><strong>kwargs</strong> – Keyword arguments for the function.</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="jarvis_ui.modules.timer.RepeatedTimer.cancel">
<span class="sig-name descname"><span class="pre">cancel</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#jarvis_ui.modules.timer.RepeatedTimer.cancel" title="Permalink to this definition"></a></dt>
<dd><p>Initiate cancellation.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="jarvis_ui.modules.timer.RepeatedTimer.start">
<span class="sig-name descname"><span class="pre">start</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#jarvis_ui.modules.timer.RepeatedTimer.start" title="Permalink to this definition"></a></dt>
<dd><p>Trigger target function if timer isn’t running already.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="jarvis_ui.modules.timer.RepeatedTimer.stop">
<span class="sig-name descname"><span class="pre">stop</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#jarvis_ui.modules.timer.RepeatedTimer.stop" title="Permalink to this definition"></a></dt>
<dd><p>Stop the timer and cancel all futures.</p>
</dd></dl>

</dd></dl>

</section>
<section id="module-jarvis_ui.executables.speaker">
<span id="speaker"></span><h1>Speaker<a class="headerlink" href="#module-jarvis_ui.executables.speaker" title="Permalink to this heading"></a></h1>
Expand Down Expand Up @@ -492,6 +538,24 @@ <h1>Models<a class="headerlink" href="#models" title="Permalink to this heading"

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="jarvis_ui.executables.starter.heart_beat">
<span class="sig-prename descclassname"><span class="pre">jarvis_ui.executables.starter.</span></span><span class="sig-name descname"><span class="pre">heart_beat</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">status_manager</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">DictProxy</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">NoReturn</span></span></span><a class="headerlink" href="#jarvis_ui.executables.starter.heart_beat" title="Permalink to this definition"></a></dt>
<dd><p>Initiate health check with the server.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>status_manager</strong> – Shared multiprocessing dict to update in case of failed health check.</p>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p>Heart beat should be set no lesser than 5 seconds to avoid throttling and no longer than an hour.</p></li>
<li><p>Maintains a consecutive failure threshold of 5, as a single failed health check doesn’t warrant a restart.</p></li>
</ul>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="jarvis_ui.executables.starter.processor">
<span class="sig-prename descclassname"><span class="pre">jarvis_ui.executables.starter.</span></span><span class="sig-name descname"><span class="pre">processor</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#jarvis_ui.executables.starter.processor" title="Permalink to this definition"></a></dt>
Expand Down Expand Up @@ -670,6 +734,7 @@ <h3><a href="#">Table of Contents</a></h3>
<li><a class="reference internal" href="#module-jarvis_ui.executables.listener">Listener</a></li>
<li><a class="reference internal" href="#module-jarvis_ui.modules.logger">Logger</a></li>
<li><a class="reference internal" href="#models">Models</a></li>
<li><a class="reference internal" href="#module-jarvis_ui.modules.timer">Repeated Timer</a></li>
<li><a class="reference internal" href="#module-jarvis_ui.executables.speaker">Speaker</a></li>
<li><a class="reference internal" href="#module-jarvis_ui.executables.starter">Starter</a></li>
<li><a class="reference internal" href="#module-jarvis_ui.modules.peripherals">Peripherals</a></li>
Expand Down
Binary file modified docs/objects.inv
Binary file not shown.
5 changes: 5 additions & 0 deletions docs/py-modindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ <h1>Python Module Index</h1>
<td>&#160;&#160;&#160;
<a href="index.html#module-jarvis_ui.modules.peripherals"><code class="xref">jarvis_ui.modules.peripherals</code></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&#160;&#160;&#160;
<a href="index.html#module-jarvis_ui.modules.timer"><code class="xref">jarvis_ui.modules.timer</code></a></td><td>
<em></em></td></tr>
</table>


Expand Down
Loading

0 comments on commit 39a831d

Please sign in to comment.