Skip to content

Commit 2926cde

Browse files
committed
Update docs and refactor some core code
1 parent f89e821 commit 2926cde

File tree

20 files changed

+795
-42
lines changed

20 files changed

+795
-42
lines changed

docs-src/css/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.navbar-brand {
2+
background: no-repeat url("/images/inengine-logo-32-alt.png");
3+
}
4+
15
.navbar-default {
26
background: #0a69fa;
37
}

docs-src/queuing.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Queuing
2+
3+
## Prerequisites
4+
5+
Redis is required to use the InEngine.NET Queue feature.
6+
It can be installed on Ubuntu with this command:
7+
8+
```bash
9+
sudo apt-get install redis-server
10+
```
11+
12+
Start Redis with this command:
13+
14+
```bash
15+
sudo service redis start
16+
```
17+
18+
<div class="alert alert-info">
19+
It is highly recommended to <a href="https://redis.io/topics/security#authentication-feature">set a password</a> for Redis.
20+
</div>
21+
22+
## Working with Queues
23+
24+
### Publishing Commands
25+
26+
#### Programmatically
27+
28+
[Commands](commands) can be published programmatically with the **InEngine.Core.Queue.Broker** class:
29+
30+
```csharp
31+
Broker.Make().Publish(new MyCommand());
32+
```
33+
34+
#### From the Command Line
35+
Commands can be published from the command line as well.
36+
Note that all queue commands reside in the **InEngine.Core** plugin.
37+
This is an example of how to publish a command from the CLI by specifying the commands assembly, class name, and arguments:
38+
39+
```bash
40+
InEngineCli.exe -pInEngine.Core queue:publish --command-assembly=MyCommandPlugin.dll --command-class=MyCommand --args "text=bar"
41+
```
42+
43+
There is an "Echo" command in the *InEngine.Core* package. It is useful for end-to-end testing with the queue feature.
44+
45+
```bash
46+
InEngineCli.exe -pInEngine.Core queue:publish --command-assembly=InEngine.Core.dll --command-class=InEngine.Core.Commands.Echo --args "text=foo"
47+
```
48+
49+
### Consuming Commands
50+
51+
#### Programmatically
52+
Consuming a command is also accomplished with the Broker class:
53+
54+
```csharp
55+
Broker.Make().Consume();
56+
```
57+
58+
Both methods take an optional second argument to indicate if the secondary queue should be used instead of the primary queue.
59+
60+
```csharp
61+
// Uses secondary queue.
62+
Broker.Make().Consume(true);
63+
```
64+
65+
Commands can be consumed from the command line as well with this simple command:
66+
67+
#### From the Command Line
68+
69+
```bash
70+
InEngineCli.exe -pInEngine.Core queue:consume
71+
```
72+
73+
use the **--secondary** switch to consume the secondary queue instead of the primary queue:
74+
75+
```bash
76+
InEngineCli.exe -pInEngine.Core queue:consume --secondary
77+
```
78+
79+
#### With the Scheduler
80+
81+
The InEngine scheduler is needed to consume queued messages in the background.
82+
There are a variety of [ways to run the scheduler](scheduling/#running-the-scheduler).

docs-src/scheduling.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
[Commands](commands) can be scheduled to run by leveraging the InEngineScheduler.exe program, available as a download from a recent [release](https://github.com/InEngine-NET/InEngine.NET/releases).
44

5-
## Manually Running the Scheduler
5+
## Running the Scheduler
6+
7+
### Manually from the CLI
68

79
Running the scheduler from the CommandLine is useful for debugging or local development. Simply run *InEngineScheduler.exe* from the command line.
810

@@ -16,37 +18,37 @@ It can also be run on Mac/Linux with Mono.
1618
mono InEngineScheduler.exe
1719
```
1820

19-
## Running as a Windows Service
21+
### On Windows as a Service
2022

2123

22-
### Installing as a Windows Service
24+
#### Installing
2325
Run the Install.ps1 PowerShell script in the scheduler directory to install the scheduler in place. The script needs to be run as an administrator. The script will register the service at the location where the script is run.
2426

2527
```bash
2628
ps Install.ps1
2729
```
2830

29-
### Uninstalling the Windows Service
31+
#### Uninstalling
3032

3133
Simply run the **Uninstall.ps1** script with elevated permissions to unregister the service.
3234

3335
```bash
3436
ps Uninstall.ps1
3537
```
3638

37-
## Running with Supervisor (on Linux)
39+
### On Linux with Supervisor
3840

3941
Supervisor is a process control system for Linux. It has extensive [documentation](http://supervisord.org/index.html), but the following should be enough to get started.
4042

41-
### Installing Supervisor
43+
#### Installing Supervisor
4244

4345
This command installs Supervisor on Ubuntu:
4446

4547
```
4648
sudo apt-get install supervisor
4749
```
4850

49-
### Configuring Supervisor
51+
#### Configuring Supervisor
5052

5153
Supervisor configuration files are stored in the **/etc/supervisor/conf.d** directory. Multiple files can be created in this directory to specify different programs, or multiple instances of the same program, for Supervisor to monitor. Copy this sample config into a file called **/etc/supervisor/conf.d/inengine-scheduler.conf**.
5254

@@ -63,7 +65,7 @@ redirect_stderr=true
6365
stdout_logfile=./scheduler.log
6466
```
6567

66-
### Starting Supervisor
68+
#### Starting Supervisor
6769

6870
Whenever a configuration change happens to files in the Supervisor config files, Supervisor needs to be instructed to reload its configuration.
6971

docs/404.html

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,22 @@
4949
<li >
5050
<a href="/">Getting Started</a>
5151
</li>
52-
<li >
53-
<a href="/commands/">Commands</a>
52+
<li class="dropdown">
53+
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Documentation <b class="caret"></b></a>
54+
<ul class="dropdown-menu">
55+
56+
<li >
57+
<a href="/commands/">Commands</a>
58+
</li>
59+
60+
<li >
61+
<a href="/scheduling/">Scheduling</a>
62+
</li>
63+
64+
<li >
65+
<a href="/queuing/">Queuing</a>
66+
</li>
67+
</ul>
5468
</li>
5569
</ul>
5670

docs/commands/index.html

Lines changed: 92 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,22 @@
4949
<li >
5050
<a href="..">Getting Started</a>
5151
</li>
52-
<li class="active">
53-
<a href="./">Commands</a>
52+
<li class="dropdown active">
53+
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Documentation <b class="caret"></b></a>
54+
<ul class="dropdown-menu">
55+
56+
<li class="active">
57+
<a href="./">Commands</a>
58+
</li>
59+
60+
<li >
61+
<a href="../scheduling/">Scheduling</a>
62+
</li>
63+
64+
<li >
65+
<a href="../queuing/">Queuing</a>
66+
</li>
67+
</ul>
5468
</li>
5569
</ul>
5670

@@ -65,8 +79,8 @@
6579
<i class="fa fa-arrow-left"></i> Previous
6680
</a>
6781
</li>
68-
<li class="disabled">
69-
<a rel="prev" >
82+
<li >
83+
<a rel="prev" href="../scheduling/">
7084
Next <i class="fa fa-arrow-right"></i>
7185
</a>
7286
</li>
@@ -86,9 +100,11 @@
86100
<li class="main active"><a href="#commands">Commands</a></li>
87101
<li><a href="#create-a-command">Create a Command</a></li>
88102
<li><a href="#run-a-command">Run a Command</a></li>
89-
<li><a href="#discover-commands-plugins">Discover Commands Plugins</a></li>
103+
<li><a href="#discover-command-plugins">Discover Command Plugins</a></li>
90104
<li><a href="#discover-commands-in-a-plugin">Discover Commands in a Plugin</a></li>
91105
<li><a href="#print-help-text-for-a-plugins-commands">Print Help Text for a Plugin's Commands</a></li>
106+
<li><a href="#logging">Logging</a></li>
107+
<li><a href="#progress-bar">Progress Bar</a></li>
92108
</ul>
93109
</div></div>
94110
<div class="col-md-9" role="main">
@@ -178,7 +194,7 @@ <h2 id="run-a-command">Run a Command</h2>
178194
<pre><code class="bash">InEngineCli.exe -pMyCommandPlugin my-command
179195
</code></pre>
180196

181-
<h2 id="discover-commands-plugins">Discover Commands Plugins</h2>
197+
<h2 id="discover-command-plugins">Discover Command Plugins</h2>
182198
<p>Run InEngineCli.exe without any arguments to see a list of arguments.</p>
183199
<pre><code class="text">Available plugins...
184200
InEngine.Commands
@@ -191,8 +207,8 @@ <h2 id="discover-commands-in-a-plugin">Discover Commands in a Plugin</h2>
191207
</code></pre>
192208

193209
<p>The <strong>InEngine.Core</strong> library is itself a plugin that contains queue related commands.
194-
This is the help output for the core plugin.</p>
195-
<pre><code class="text">InEngine 3.1.0
210+
As an example, this is the help output for the core plugin.</p>
211+
<pre><code class="text">InEngine 3.x
196212
Copyright © Ethan Hann 2017
197213

198214
queue:publish Publish a command message to a queue.
@@ -211,12 +227,79 @@ <h2 id="print-help-text-for-a-plugins-commands">Print Help Text for a Plugin's C
211227
</code></pre>
212228

213229
<p>The <strong>InEngine.Core</strong> plugin's command to clear the InEngine.NET's queues produces this help message. </p>
214-
<pre><code class="text">InEngine 3.1.0
230+
<pre><code class="text">InEngine 3.x
215231
Copyright © Ethan Hann 2017
216232

217233
--processing-queue Clear the processing queue.
218234

219235
--secondary Clear the secondary queue.
236+
</code></pre>
237+
238+
<h2 id="logging">Logging</h2>
239+
<p>The <strong>InEngine.Core.AbstractCommand</strong> class provides a Logger property. It implements the <strong>NLog.ILogger</strong> interface.</p>
240+
<pre><code class="csharp">using System;
241+
using InEngine.Core;
242+
243+
namespace MyCommandPlugin
244+
{
245+
public class MyCommand : ICommand
246+
{
247+
public override CommandResult Run()
248+
{
249+
Logger.Trace(&quot;Sample trace message&quot;);
250+
Logger.Debug(&quot;Sample debug message&quot;);
251+
Logger.Info(&quot;Sample informational message&quot;);
252+
Logger.Warn(&quot;Sample warning message&quot;);
253+
Logger.Error(&quot;Sample error message&quot;);
254+
Logger.Fatal(&quot;Sample fatal error message&quot;);
255+
return new CommandResult(true);
256+
}
257+
}
258+
}
259+
</code></pre>
260+
261+
<p>Setup an <a href="https://github.com/NLog/NLog/wiki/Tutorial#configuration">NLog configuration</a> file, something like this...</p>
262+
<pre><code class="xml">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
263+
&lt;nlog xmlns=&quot;http://www.nlog-project.org/schemas/NLog.xsd&quot;
264+
xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
265+
266+
&lt;targets&gt;
267+
&lt;target name=&quot;logfile&quot; xsi:type=&quot;File&quot; fileName=&quot;file.txt&quot; /&gt;
268+
&lt;target name=&quot;console&quot; xsi:type=&quot;Console&quot; /&gt;
269+
&lt;/targets&gt;
270+
271+
&lt;rules&gt;
272+
&lt;logger name=&quot;*&quot; minlevel=&quot;Trace&quot; writeTo=&quot;logfile&quot; /&gt;
273+
&lt;logger name=&quot;*&quot; minlevel=&quot;Info&quot; writeTo=&quot;console&quot; /&gt;
274+
&lt;/rules&gt;
275+
&lt;/nlog&gt;
276+
</code></pre>
277+
278+
<h2 id="progress-bar">Progress Bar</h2>
279+
<p>The <strong>InEngine.Core.AbstractCommand</strong> class provides a ProgressBar property. This is how it is used.</p>
280+
<pre><code class="csharp">using InEngine.Core;
281+
282+
namespace MyCommandPlugin
283+
{
284+
public class MyCommand : AbstractCommand
285+
{
286+
public override CommandResult Run()
287+
{
288+
// Define the ticks (aka steps) for the command...
289+
var maxTicks = 100000;
290+
SetProgressBarMaxTicks(maxTicks);
291+
292+
// Do some work...
293+
for (var i = 0; i &lt;= maxTicks;i++)
294+
{
295+
// Update the command's progress
296+
UpdateProgress(i);
297+
}
298+
299+
return new CommandResult(true);
300+
}
301+
}
302+
}
220303
</code></pre></div>
221304
</div>
222305

docs/css/style.css

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1+
.navbar-brand {
2+
background: no-repeat url("/images/inengine-logo-32-alt.png");
3+
}
4+
15
.navbar-default {
2-
background: #2f2f2f;
6+
background: #0a69fa;
37
}
48

59
.navbar-default .navbar-nav > .active > a,
610
.navbar-default .navbar-nav > .active > a:hover,
711
.navbar-default .navbar-nav > .active > a:focus {
8-
background-color: #0f0f0f;
12+
background-color: #0a69fa;
913
}
1014

1115
.navbar-default .navbar-nav > li > a:hover,
1216
.navbar-default .navbar-nav > li > a:focus {
13-
background-color: #0f0f0f;
17+
background-color: #0a69fa;
1418
}
1519

1620
a,

docs/index.html

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,22 @@
4949
<li class="active">
5050
<a href=".">Getting Started</a>
5151
</li>
52-
<li >
53-
<a href="commands/">Commands</a>
52+
<li class="dropdown">
53+
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Documentation <b class="caret"></b></a>
54+
<ul class="dropdown-menu">
55+
56+
<li >
57+
<a href="commands/">Commands</a>
58+
</li>
59+
60+
<li >
61+
<a href="scheduling/">Scheduling</a>
62+
</li>
63+
64+
<li >
65+
<a href="queuing/">Queuing</a>
66+
</li>
67+
</ul>
5468
</li>
5569
</ul>
5670

@@ -132,5 +146,5 @@ <h4 class="modal-title" id="exampleModalLabel">Search</h4>
132146

133147
<!--
134148
MkDocs version : 0.16.3
135-
Build Date UTC : 2017-11-20 04:36:59
149+
Build Date UTC : 2017-11-20 23:31:58
136150
-->

0 commit comments

Comments
 (0)