Skip to content

Commit 0861931

Browse files
committed
Update docs
1 parent 9380111 commit 0861931

File tree

9 files changed

+251
-110
lines changed

9 files changed

+251
-110
lines changed

docs-src/commands.md

Lines changed: 82 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ namespace MyCommandPlugin
4444
}
4545
```
4646

47-
Extending the **InEngine.Core.AbstractCommand** class adds extra functionality, like a logger, a progress bar, and the ability to schedule the command using the scheduler.
47+
A command that implements ICommand can be run directly or [queued](queuing), but it cannot be [scheduled](scheduling).
48+
Extending the **InEngine.Core.AbstractCommand** class adds extra functionality, like a progress bar, and the ability to schedule the command using the scheduler.
4849
Minimally, the Run method should be overridden.
4950

5051
```c#
@@ -63,12 +64,12 @@ namespace MyCommandPlugin
6364
}
6465
```
6566

66-
6767
## Run a Command
6868

6969
Create a class that implements **InEngine.Core.IOptions** in the same assembly as the command class.
70-
Add a VerbOptions attribute from the CommandLine namespace that defines the name of the command and optional help text.
71-
The help text can be auto-generated from the attribute or manually specified in the GetUsage method.
70+
Add a VerbOptions attribute, from the CommandLine namespace, that defines the name of the command.
71+
Optional help text can also be specified in the VerbOption attribute.
72+
The help text can be auto-generated from the attribute or manually specified in the GetUsage method if desired.
7273

7374
```c#
7475
using CommandLine;
@@ -93,20 +94,20 @@ namespace MyCommandPlugin
9394

9495
Download the InEngine binary distribution, from the [GitHub Releases](https://github.com/InEngine-NET/InEngine.NET/releases) page, that matches the version of the InEngine.Core package you included.
9596

96-
Copy your project's DLLs into the same directory as inengine.exe.
97+
Copy your project's DLLs into the Plugins subdirectory included in the binary distribution.
98+
Add your plugin to the ["Plugins" list in appsettings.config](configuration) at the root of the binary distribution.
9799

98-
Run your command...
100+
Run your command:
99101

100102
```bash
101103
inengine.exe -pMyCommandPlugin my-command
102104
```
103105

104-
## Discover Command Plugins
106+
## View Available Plugins
105107

106-
Run inengine.exe without any arguments to see a list of plugins.
108+
Run inengine.exe without any arguments to see a list of plugins:
107109

108110
```text
109-
110111
___ _____ _ _ _ _____ _____
111112
|_ _|_ __ | ____|_ __ __ _(_)_ __ ___ | \ | | ____|_ _|
112113
| || '_ \| _| | '_ \ / _` | | '_ \ / _ \ | \| | _| | |
@@ -115,116 +116,138 @@ Run inengine.exe without any arguments to see a list of plugins.
115116
|___/
116117
117118
Usage:
118-
-p[<plugin_name>] [<command_name>]
119+
InEngine 3.x
120+
Copyright © 2017 Ethan Hann
121+
122+
p, plugin Plug-In to activate.
123+
124+
s, scheduler Run the scheduler.
125+
126+
c, configuration (Default: ./appsettings.json) The path to the
127+
configuration file.
128+
119129
120130
Plugins:
121-
InEngine.Commands
122131
InEngine.Core
123-
124132
```
125133

126-
## Discover Commands in a Plugin
134+
## View Commands in a Plugin
127135

128-
Run inengine.exe with only the plugin specified.
136+
Run inengine.exe with only the plugin specified:
129137

130138
```bash
131139
inengine.exe -pInEngine.Core
132140
```
133141

134-
The **InEngine.Core** library is itself a plugin that contains queue related commands.
142+
The **InEngine.Core** library is itself a plugin that contains queue-related and other commands.
135143
As an example, this is the help output for the core plugin.
136144

137145
```text
138-
139146
___ _____ _ _ _ _____ _____
140147
|_ _|_ __ | ____|_ __ __ _(_)_ __ ___ | \ | | ____|_ _|
141148
| || '_ \| _| | '_ \ / _` | | '_ \ / _ \ | \| | _| | |
142149
| || | | | |___| | | | (_| | | | | | __/_| |\ | |___ | |
143150
|___|_| |_|_____|_| |_|\__, |_|_| |_|\___(_|_| \_|_____| |_|
144151
|___/
145152
146-
Plugin: InEngine.Core
153+
Plugin:
154+
Name: InEngine.Core
155+
Version: 3.x
156+
147157
148158
Commands:
149-
null A null operation command. Literally does nothing.
150-
echo Echo some text to the console. Useful for end-to-end testing.
151-
queue:publish Publish a command message to a queue.
152-
queue:consume Consume one or more command messages from the queue.
153-
queue:length Get the number of messages in the primary and secondary queues.
154-
queue:clear Clear the primary and secondary queues.
159+
queue:publish Publish a command message to a queue.
160+
queue:consume Consume one or more command messages from the queue.
161+
queue:length Get the number of messages in the primary and secondary queues.
162+
queue:flush Clear the primary or secondary queues.
163+
queue:republish Republish failed messages to the queue.
164+
queue:peek Peek at messages in the primary or secondary queues.
165+
echo Echo some text to the console. Useful for end-to-end testing.
166+
proc Launch an arbitrary process.
155167
```
156168

157169
## Print Help Text for a Plugin's Commands
158170

159171
Run the command with the -h or --help arguments.
160172

161173
```bash
162-
inengine.exe -pInEngine.Core queue:clear -h
174+
inengine.exe -pInEngine.Core queue:publish -h
163175
```
164176

165177
The **InEngine.Core** plugin's command to clear the InEngine.NET queues produces this help message.
166178

167179
```text
168180
InEngine 3.x
169-
Copyright © Ethan Hann 2017
181+
Copyright © 2017 Ethan Hann
170182
171-
--processing-queue Clear the processing queue.
183+
--command-plugin Required. The name of a command plugin file, e.g.
184+
InEngine.Core.dll
172185
173-
--secondary Clear the secondary queue.
174-
```
186+
--command-verb A plugin command verb, e.g. echo
175187
176-
## Writing Output
188+
--command-class A command class name, e.g.
189+
InEngine.Core.Commands.AlwaysSucceed. Takes precedence
190+
over --command-verb if both are specified.
177191
178-
The **InEngine.Core.AbstractCommand** class provides some helper functions to output text to the console:
192+
--args An optional list of arguments to publish with the
193+
command.
179194
180-
```c#
181-
IWrite Newline();
182-
IWrite Info(string val);
183-
IWrite Warning(string val);
184-
IWrite Error(string val);
185-
IWrite Line(string val);
195+
--secondary (Default: False) Publish the command to the secondary
196+
queue.
186197
```
187198

199+
## Writing Output
200+
201+
The **InEngine.Core.AbstractCommand** class provides some helper functions to output text to the console, for example:
202+
188203
```c#
189204
public override void Run()
190205
{
191-
Info("Display some information");
206+
Line("Display some information");
192207
}
193208
```
194209

195-
Display an error message, use the Error method.
210+
All of these commands append a newline to the end of the specified text:
196211

197212
```c#
198-
Error("Display some information");
213+
Line("This is some text"); // Text color is white
214+
Info("Something good happened"); // Text color is green
215+
Warning("Something not so good happened"); // Text color is yellow
216+
Error("Something bad happened"); // Text color is red
199217
```
200218

201-
Display a warning message, use the Warning method.
219+
These commands are similar, but they do not append a newline:
202220

203221
```c#
204-
Error("Display some information");
222+
Text("This is some text"); // Text color is white
223+
InfoText("Something good happened"); // Text color is green
224+
WarningText("Something not so good happened"); // Text color is yellow
225+
ErrorText("Something bad happened"); // Text color is red
205226
```
206227

207-
Info, Error, and Warning messages are display in green, red, and yellow, respectively.
208-
If you want to display an uncolored line, use the Line method.
209-
Line("This is a plain line.");
210-
211-
## Logging
228+
You can also display newlines:
229+
230+
```c#
231+
Newline(); // 1 newline
232+
Newline(5); // 5 newlines
233+
Newline(10); // 10 newlines
234+
```
212235

213-
The **InEngine.Core.AbstractCommand** class provides a Logger property. It implements the **NLog.ILogger** interface.
236+
The methods can be chained together:
214237

215238
```c#
216-
public override void Run()
217-
{
218-
Logger.Trace("Sample trace message");
219-
Logger.Debug("Sample debug message");
220-
Logger.Info("Sample informational message");
221-
Logger.Warn("Sample warning message");
222-
Logger.Error("Sample error message");
223-
Logger.Fatal("Sample fatal error message");
224-
}
239+
InfoText("You have this many things: ")
240+
.Line("23")
241+
.NewLine(2)
242+
.InfoText("You have this many other things: ")
243+
.Line("34")
244+
.NewLine(2);
225245
```
226246

227-
Setup an [NLog configuration](https://github.com/NLog/NLog/wiki/Tutorial#configuration) file, something like this...
247+
## Logging
248+
249+
Any exceptions thrown by a command will be logged with NLog provided NLog is configured.
250+
The [NLog configuration](https://github.com/NLog/NLog/wiki/Tutorial#configuration) file needs to be setup with something like this:
228251

229252
```xml
230253
<?xml version="1.0" encoding="utf-8" ?>
@@ -245,7 +268,8 @@ Setup an [NLog configuration](https://github.com/NLog/NLog/wiki/Tutorial#configu
245268

246269
## Progress Bar
247270

248-
The **InEngine.Core.AbstractCommand** class provides a ProgressBar property. This is how it is used.
271+
The **InEngine.Core.AbstractCommand** class provides a ProgressBar property to show command progress in a terminal.
272+
This is how it is used:
249273

250274
```c#
251275
public override void Run()

docs-src/configuration.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ Configuration is accomplished by modifying the appsettings.json file that comes
66
```json
77
{
88
"InEngine": {
9+
"Plugins": [
10+
"path/to/MyCommandPlugin"
11+
],
912
"Queue": {
13+
"UseCompression": false,
1014
"PrimaryQueueConsumers": 16,
1115
"SecondaryQueueConsumers": 4,
1216
"QueueName": "InEngine:Queue",
@@ -20,15 +24,23 @@ Configuration is accomplished by modifying the appsettings.json file that comes
2024

2125
```
2226

23-
| Setting | Description |
24-
| ------------------------- | ------------------------- |
25-
| PrimaryQueueConsumers | The number of consumers to schedule for the primary queue. |
26-
| SecondaryQueueConsumers | The number of consumers to schedule for the secondary queue. |
27-
| QueueName | The base name of the queue, used to form the Redis Queue keys. |
28-
| RedisHost | The Redis hostname to connect to. |
29-
| RedisPort | Redis's port. |
30-
| RedisDb | The Redis database - 0-15 |
31-
| RedisPassword | The Redis auth password |
3227

28+
## Top-level Settings
3329

30+
| Setting | Type | Description |
31+
| ------------------------- | ----------------- | --------------------------------------------------------------------------------- |
32+
| Plugins | array of strings | A list of paths of plugin assemblies, with ".dll" omitted from the assembly name. |
3433

34+
35+
## Queue Settings
36+
37+
| Setting | Type | Description |
38+
| ------------------------- | --------- | --------------------------------------------------------------------- |
39+
| UseCompression | bool | A situation performance optimization that compresses queued messages. |
40+
| PrimaryQueueConsumers | string | The number of consumers to schedule for the secondary queue. |
41+
| SecondaryQueueConsumers | string | The number of consumers to schedule for the secondary queue. |
42+
| QueueName | string | The base name of the queue, used to form the Redis Queue keys. |
43+
| RedisHost | string | The Redis hostname to connect to. |
44+
| RedisPort | integer | Redis's port. |
45+
| RedisDb | integer | The Redis database - 0-15 |
46+
| RedisPassword | string | The Redis auth password |

docs-src/queuing.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ It is highly recommended to <a href="https://redis.io/topics/security#authentica
2525

2626
#### Programmatically
2727

28-
[Commands](commands) can be published programmatically with the **InEngine.Core.Queue.Broker** class:
28+
[Commands](commands) can be published programmatically with the **InEngine.Core.Queuing.Broker** class:
2929

3030
```c#
3131
Broker.Make().Publish(new MyCommand());
@@ -37,13 +37,19 @@ Note that all queue commands reside in the **InEngine.Core** plugin.
3737
This is an example of how to publish a command from the CLI by specifying the commands assembly, class name, and arguments:
3838

3939
```bash
40-
inengine.exe -pInEngine.Core queue:publish --command-assembly=MyCommandPlugin.dll --command-class=MyCommand --args "text=bar"
40+
inengine.exe -pInEngine.Core queue:publish --command-plugin=MyCommandPlugin.dll --command-class=MyCommand --args "text=bar"
4141
```
4242

4343
There is an "Echo" command in the *InEngine.Core* package. It is useful for end-to-end testing with the queue feature.
4444

4545
```bash
46-
inengine.exe -pInEngine.Core queue:publish --command-assembly=InEngine.Core.dll --command-class=InEngine.Core.Commands.Echo --args "text=foo"
46+
inengine.exe -pInEngine.Core queue:publish --command-plugin=InEngine.Core.dll --command-class=InEngine.Core.Commands.Echo --args "text=foo"
47+
```
48+
49+
The command verb can also be specified instead of the full class name:
50+
51+
```bash
52+
inengine.exe -pInEngine.Core queue:publish --command-plugin=InEngine.Core.dll --command-verb=echo--args "text=foo"
4753
```
4854

4955
### Consuming Commands
@@ -55,11 +61,11 @@ Consuming a command is also accomplished with the Broker class:
5561
Broker.Make().Consume();
5662
```
5763

58-
Both methods take an optional second argument to indicate if the secondary queue should be used instead of the primary queue.
64+
The make method takes an optional second argument to indicate if the secondary queue should be used instead of the primary queue.
5965

6066
```c#
6167
// Uses secondary queue.
62-
Broker.Make().Consume(true);
68+
Broker.Make(true).Consume();
6369
```
6470

6571
Commands can be consumed from the command line as well with this simple command:
@@ -70,7 +76,7 @@ Commands can be consumed from the command line as well with this simple command:
7076
inengine.exe -pInEngine.Core queue:consume
7177
```
7278

73-
Use the **--secondary** switch to consume the secondary queue instead of the primary queue:
79+
Use the **--secondary** argument to consume the secondary queue instead of the primary queue:
7480

7581
```bash
7682
inengine.exe -pInEngine.Core queue:consume --secondary
@@ -84,21 +90,25 @@ There are a variety of [ways to run the scheduler](scheduling/#running-the-sched
8490

8591
## Primary and Secondary Queue
8692

87-
Other than the fact that the primary queue is used by default, there is difference between the primary and secondary queues.
93+
Other than the fact that the primary queue is used by default, there is no difference between the primary and secondary queues.
8894
However, it is often desirable to have more than 1 queue.
8995
For example, long running jobs might be sent to the secondary queue,
9096
while jobs that are expected to finish after only a few moments are sent to the primary queue.
9197

92-
What about 3, 4, or 900 queues? Numerous queues gets to be a pain to manage and, practically speaking, is probably unnecessary.
98+
What about 3, 4, or 900 queues? Managing numerous queues gets to be a pain and, practically speaking, is probably unnecessary.
9399
If it is desirable, different [configuration files](configuration) can be used to run multiple instances of InEngine.NET.
94-
Simply create a new config file with a new QueueName setting and point inengine.exe at it.
100+
Simply create a new [config file](configuration) with a new QueueName setting and point inengine.exe at it with the -c argument:
101+
102+
```bash
103+
inengine.exe -cMyCustomSettingsFile.json -pInEngine.Core queue:consume
104+
```
95105

96106
## Message Compression
97107

98108
Messages can be compressed when saved in the queue.
99109
It is important to understand the trade-offs of this feature before enabling it.
100-
Compressing messages takes more CPU resources and might negatively impact queueing throughput if the queued commands do not have a lot of internal state.
101-
Put simply, if the commands are too small to benefit from being compressed, then compressing them wastes resources.
110+
If the queued commands are too small to benefit from being compressed, then compressing them wastes resources.
111+
Compressing messages takes more CPU resources and might negatively impact queue throughput if the queued commands do not have a lot of internal state.
102112

103113
If the commands have a lot of internal state, then this feature will reduce the queue's memory consumption.
104114
Also, in a high-throughput scenario, where network bandwidth is limited, this feature can greatly reduce the amount of bandwidth used.

0 commit comments

Comments
 (0)