You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: md/app.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,7 +70,7 @@ public class MyModule implements Jooby.Module {
70
70
}
71
71
```
72
72
73
-
The `onStart` callbacks are part of bootstrap and executed before server is ready. The `onStarted` callbacks are executed when server is ready.
73
+
The `onStart` callbacks are part of bootstrap and executed before the server is ready. The `onStarted` callbacks are executed when the server is ready.
74
74
75
75
Modules are covered later all you need to know now is that you can start/stop module as you usually do from your application.
76
76
@@ -95,7 +95,7 @@ Callback order is preserved:
95
95
}
96
96
```
97
97
98
-
Order is useful for service dependencies, like `ServiceB` should be started after `ServiceA`.
98
+
Order is useful for service dependencies, for example if `ServiceB` should be started after `ServiceA`.
99
99
100
100
### service registry
101
101
@@ -117,7 +117,7 @@ You have access to the the service registry from start/stop events:
Copy file name to clipboardExpand all lines: md/async.md
+20-20Lines changed: 20 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,14 @@
1
1
# thread model
2
2
3
-
You can see {{jooby}} as an `event loop server` thanks to the supported web servers: {{netty_server}}, {{jetty_server}} and {{undertow_server}}. Being {{netty_server}} the default web server.
3
+
You can see {{jooby}} as an `event loop server` thanks to the supported web servers: {{netty_server}}, {{jetty_server}} and {{undertow_server}}. The default web server is {{netty_server}}.
4
4
5
5
{{jooby}} isn't a traditional `thread server` where a HTTP request is bound to a thread.
6
6
7
7
In {{jooby}} all the HTTP IO operations are performed in async & non blocking fashion. HTTP IO operations run in an IO thread (a.k.a event loop) while the application logic (your code) **always run in a worker thread**.
8
8
9
9
## worker threads
10
10
11
-
The **worker thread** pool is provided by the web server: {{netty_server}}, {{jetty_server}} and {{undertow_server}}. To simplify application programming you can **block a worker thread**, for example you can safely run a **jdbc** query in a **worker thread**:
11
+
The **worker thread** pool is provided by one of the supported web servers: {{netty_server}}, {{jetty_server}} or {{undertow_server}}. To simplify application programming you can **block a worker thread**, for example you can safely run a **jdbc** query in a **worker thread**:
12
12
13
13
```java
14
14
{
@@ -22,11 +22,11 @@ The **worker thread** pool is provided by the web server: {{netty_server}}, {{je
22
22
}
23
23
```
24
24
25
-
Here the web server can accept as many connection it can (as its on non blocking) while the worker thread might blocks.
25
+
The web server can accept as many connections it can (as its on non blocking) while the worker thread might block.
26
26
27
-
Default worker thread pool is `20/100`. The correct/right size depends on your**business** and **work load** your application is suppose to handle. We suggest you to start with default setup and see how it goes, later you can reduce or increase the thread pool.
27
+
The default worker thread pool is `20/100`. The optimal size depends on the**business** and **work load** your application is suppose to handle. We suggest you to start with the default setup and see how it goes, later you can reduce or increase the thread pool.
28
28
29
-
In {{jooby}} we favor simplicity over complexity that is why your **code** can block, still there are more advanced setup that allow you to build async and reactive applications.
29
+
In {{jooby}} we favor simplicity over complexity that is why your **code** can block, still there are more advanced options that allow you to build async and reactive applications.
30
30
31
31
## deferred
32
32
@@ -54,7 +54,7 @@ MVC API:
54
54
}
55
55
```
56
56
57
-
Previousexamples are just `syntax sugar` for:
57
+
The previous examples are just `syntactic sugar` for:
58
58
59
59
```
60
60
returnnewDeferred(deferred -> {
@@ -66,7 +66,7 @@ Previous examples are just `syntax sugar` for:
66
66
});
67
67
```
68
68
69
-
There is more `syntax sugar` if you add the [AsyncMapper]({{defdocs}}/AsyncMapper.html) to your application:
69
+
You can get more `syntactic sugar` if you add the [AsyncMapper]({{defdocs}}/AsyncMapper.html) to your application:
70
70
71
71
ScriptAPI:
72
72
@@ -95,9 +95,9 @@ MVC API:
95
95
}
96
96
```
97
97
98
-
The [AsyncMapper]({{defdocs}}/AsyncMapper.html) convert `java.util.concurrent.Callable` and `java.util.concurrent.CompletableFuture` objects to {{deferred}} objects.
98
+
The [AsyncMapper]({{defdocs}}/AsyncMapper.html) converts `java.util.concurrent.Callable` and `java.util.concurrent.CompletableFuture` objects to {{deferred}} objects.
99
99
100
-
Another important thing to notice is that the deferred run in the **caller thread** (i.e. worker thread), so by default there is **no context switch**involvewhile running a {{deferred}} result:
100
+
Another important thing to notice is that the deferred run in the **caller thread** (i.e. worker thread), so by default there is **no context switch**involvedwhile running a {{deferred}} result:
101
101
102
102
```java
103
103
{
@@ -111,15 +111,15 @@ Another important thing to notice is that the deferred run in the **caller threa
111
111
}
112
112
```
113
113
114
-
You might first see this as a bad thing, but is actually a good decision, because:
114
+
You might see this as a bad thing at first, but it's actually a good decision, because:
115
115
116
116
* It is super easy to setup a default executor (we will see how soon)
117
117
118
118
* Provides better integration with async & reactive libraries. A `direct` executor avoid the need of switching to a new thread and then probably dispatch (again) to a different thread provided by a library.
119
119
120
120
## executor
121
121
122
-
Aswe said before, the default executor run in the caller thread (a.k.a direct executor).Let's see how to override the default executor:
122
+
As previously mentioned, the default executor runs in the caller thread (a.k.a direct executor). Let's see how to override the default executor:
123
123
124
124
```java
125
125
{
@@ -131,7 +131,7 @@ As we said before, the default executor run in the caller thread (a.k.a direct e
131
131
}
132
132
```
133
133
134
-
Done! Now all our {{deferred}} result run in a `ForkJoinPool`. It also possible to specify an alternative executor:
134
+
Done!Now all our {{deferred}} results run in a `ForkJoinPool`.It's also possible to specify an alternative executor:
Worth mention the [executor(ExecutorService)]({{defdocs}}/Jooby.html#executor-java.util.concurrent.ExecutorService-) methods automatically `shutdown` at application shutdown time.
178
+
It's worth mentioning that the [executor(ExecutorService)]({{defdocs}}/Jooby.html#executor-java.util.concurrent.ExecutorService-) methods automatically `shutdown` at application shutdown time.
179
179
180
180
## promise
181
181
@@ -216,7 +216,7 @@ MVC API:
216
216
}
217
217
```
218
218
219
-
The **"promise"** version of {{deferred}} object is a key concept for integrating with external libraries.
219
+
The**"promise"** version of the {{deferred}} object is a key concept for integrating with external libraries.
220
220
221
221
## advanced configuration
222
222
@@ -226,7 +226,7 @@ Suppose you want to build a truly async application and after a **deep analysis*
226
226
*Call a remote service
227
227
*Make a CPU intensive computation
228
228
229
-
These are the 3 points where your application is suppose to block and wait for a result.
229
+
These are the 3 points where your application is supposed to block and wait for a result.
230
230
231
231
Let's start by reducing the **worker thread pool** to the number of **available processors**:
232
232
@@ -247,9 +247,9 @@ Let's create a custom thread pool for each blocking access:
247
247
}
248
248
```
249
249
250
-
For `database` access, we use a `cached` executor that will grow without a limit but free and release thread that are idle after `60s`.
250
+
For `database` access, we use a `cached` executor that will grow without a limit but free and release threads that are idle after `60s`.
251
251
252
-
For `remote` service, we use a `fixed` executor of `32` thread. The number here: `32` is just a random number for the purpose of the example.
252
+
For `remote` service, we use a `fixed` executor of `32` threads. The number here: `32` is just a random number for the purpose of the example.
253
253
254
254
For `intensive` computation, we use a `single` thread executor. Computation is too expensive and we want **one and only one** running at any time.
255
255
@@ -314,14 +314,14 @@ Here is the same example with [rx java](https://github.com/ReactiveX/RxJava):
314
314
}
315
315
```
316
316
317
-
Main difference are:
317
+
The main differences are:
318
318
319
319
* we keep the default executor: `direct`. So we don't create a new thread and avoid context switching.
320
320
* we use {{deferred}} object as `promise` and integrate with [rx java](https://github.com/ReactiveX/RxJava).
321
321
* different thread pool semantic is done via [rx schedulers](http://reactivex.io/documentation/scheduler.html).
322
322
323
323
This is just one more example to demonstrate the value of the {{deferred}} object, because we provide an [rxjava](/doc/rxjava) module which takes care of binding {{deferred}} object into `Observables`.
324
324
325
-
That's all about {{deferred}} object, it allows you to build async and reactive applications and at the same time:**keep it simple** (Jooby design goal).
325
+
That sums up everything about the {{deferred}} object. It allows you to build async and reactive applications and at the same time:**keep it simple** (a Jooby design goal).
326
326
327
-
Also, we invite you to checkout the available [async/reactive modules](/doc/async).
327
+
You're also invited to check out the available [async/reactive modules](/doc/async).
Copy file name to clipboardExpand all lines: md/conf.md
+14-12Lines changed: 14 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
# conf, env and logging
2
2
3
-
Jooby delegates configuration management to [Config library](https://github.com/typesafehub/config).
3
+
Jooby delegates configuration management to the [Config library](https://github.com/typesafehub/config).
4
4
5
-
By defaults Jooby expects to find an ```application.conf``` file at the root of classpath. You can find the `.conf` file under `conf` classpath directory.
5
+
By defaults Jooby expects to find an ```application.conf``` file at the root of classpath. You can find the `.conf` file under the `conf` classpath directory.
6
6
7
7
## getting properties
8
8
@@ -59,7 +59,7 @@ Automatic type conversion is provided when a type:
59
59
60
60
6) Has a static method **forName** that accepts a single **String** argument. Like ```java.nio.charset.Charset```
61
61
62
-
You're free to inject the entirely```com.typesafe.config.Config``` object or `sub-path/tree` of it.
62
+
You're free to inject the entire```com.typesafe.config.Config``` object or `sub-path/tree` of it.
63
63
64
64
## environment
65
65
@@ -69,7 +69,7 @@ This special property is represented at runtime with the [Env]({{apidocs}}/org/j
69
69
70
70
For example: a module might decided to create a connection pool, cache, etc when ```application.env``` isn't set to `dev`.
71
71
72
-
The `application.env` property can be set as command line argument too:
72
+
The `application.env` property can be set as command line argument as well:
73
73
74
74
Using a `fat jar`:
75
75
@@ -80,9 +80,9 @@ Using [stork](/doc/stork):
80
80
81
81
bin/myapp --start prod
82
82
83
-
## turn on/off features
83
+
## turning features on or off
84
84
85
-
As described before the ```application.env``` property defines the environment where the application is being executed. It is possible to turn on/off specific features base on the application environment:
85
+
As described before, the ```application.env``` property defines the environment where the application is being executed. It's possible to turn on/off specific features based on the application environment:
86
86
87
87
```java
88
88
{
@@ -108,7 +108,7 @@ There is a `~` (complement) operator:
108
108
}
109
109
```
110
110
111
-
The ```environment callback``` has access to ```config``` object, see:
111
+
The ```environment callback``` has access to the ```config``` object, see:
112
112
113
113
```java
114
114
{
@@ -141,7 +141,7 @@ Here is the list of special properties available in Jooby:
141
141
142
142
## precedence
143
143
144
-
Configuration files are loaded in the following order (first-listed are higher priority)
144
+
Configuration files are loaded in the following order:
145
145
146
146
* system properties
147
147
* arguments properties
@@ -150,6 +150,8 @@ Configuration files are loaded in the following order (first-listed are higher p
150
150
* ([application].[conf])?
151
151
*[module].[conf]*
152
152
153
+
The first occurence of a property will take precedence.
154
+
153
155
### system properties
154
156
155
157
System properties can override any other property. A system property is set at startup time, like:
@@ -188,7 +190,7 @@ The default `classpath conf` file: `application.conf`
188
190
189
191
### [module].[conf]
190
192
191
-
A [Module]({{defdocs}}/Jooby.Module.html) might have define his own set of (default) properties via [Module.config]({{defdocs}}/Jooby.Module.html#config--) method.
193
+
A [Module]({{defdocs}}/Jooby.Module.html) might have defined its own set of (default) properties via the[Module.config]({{defdocs}}/Jooby.Module.html#config--) method.
192
194
193
195
```java
194
196
{
@@ -198,7 +200,7 @@ A [Module]({{defdocs}}/Jooby.Module.html) might have define his own set of (defa
198
200
199
201
### custom .conf
200
202
201
-
As we said before, the default `conf` file is `application.conf`, but you can use any other name you want:
203
+
As mentioned earlier, the default `conf` file is `application.conf`, but you can use whatever name you prefer:
202
204
203
205
```java
204
206
{
@@ -228,7 +230,7 @@ As we said before, the default `conf` file is `application.conf`, but you can us
228
230
}
229
231
```
230
232
231
-
* Starting the application in `dev` produces `conf` tree similar to:
233
+
* Starting the application in `dev` produces a `conf` tree similar to:
232
234
233
235
```
234
236
.
@@ -241,7 +243,7 @@ As we said before, the default `conf` file is `application.conf`, but you can us
241
243
└── ...
242
244
```
243
245
244
-
* Starting the application in `prod` produces `conf` tree similar to:
246
+
* Starting the application in `prod` produces a `conf` tree similar to:
0 commit comments