Skip to content

Commit eca6258

Browse files
committed
Update documentation
1 parent 9c2e149 commit eca6258

File tree

12 files changed

+439
-363
lines changed

12 files changed

+439
-363
lines changed

src/main/docs/guide/async.adoc

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
To use the Async framework you should add a dependency on the `async` plugin to your `build.gradle` file:
2+
3+
[source,groovy,subs="attributes"]
4+
.build.gradle
5+
----
6+
implementation "org.graceframework.plugins:async:{version}"
7+
----
8+
9+
By default the `Promises` static methods use an instance of `PromiseFactory`. This `PromiseFactory` interface has various implementations.
10+
The default implementation is link:{api}/org/grails/async/factory/future/CachedThreadPoolPromiseFactory.html[CachedThreadPoolPromiseFactory] which uses a thread pool that will create threads as needed (the same as `java.util.concurrent.Executors.newCachedThreadPool()`)
11+
12+
However, the design of the promises framework is such that you can swap out the underlying implementation for your own or one of the pre-supported implementations.
13+
For example to use RxJava 1.x simply add the RxJava dependency to `build.gradle`:
14+
15+
[source,groovy,subs="attributes"]
16+
.build.gradle
17+
----
18+
implementation "org.graceframework:grace-async-rxjava:{version}"
19+
----
20+
21+
The following table summarizes async framework support and the necessary dependency:
22+
23+
.PromiseFactory Implementations
24+
|===
25+
|Framework | Dependency | Implementation Class
26+
27+
|GPars 1.2.x
28+
|`grace-async-gpars`
29+
|`org.grails.async.factory.gpars.GparsPromiseFactory`
30+
31+
|RxJava 1.2.x
32+
|`grace-async-rxjava`
33+
|`org.grails.async.factory.rxjava.RxPromiseFactory`
34+
35+
|RxJava 2.x
36+
|`grace-async-rxjava2`
37+
|`org.grails.async.factory.rxjava2.RxPromiseFactory`
38+
39+
|RxJava 3.x
40+
|`grace-async-rxjava3`
41+
|`org.grails.async.factory.rxjava3.RxPromiseFactory`
42+
43+
|===

src/main/docs/guide/events.adoc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
Grails 3.3 introduces a new Events API that replaces the previous implementation that was based on Reactor 2.x (which is no longer maintained and deprecated).
1+
This project introduces a new Events API that replaces the previous implementation that was based on Reactor 2.x (which is no longer maintained and deprecated).
22

3-
In Grails 3.3 and above a new link:{api}/grails/events/bus/EventBus.html[EventBus] abstraction has been introduced. Like the `PromiseFactory` notion, there are implementations of the `EventBus` interface for common asynchronous frameworks like GPars and RxJava.
3+
The Events framework introduces a new link:{api}/grails/events/bus/EventBus.html[EventBus] abstraction.
4+
Like the `PromiseFactory` notion, there are implementations of the `EventBus` interface for common asynchronous frameworks like GPars and RxJava.
45

5-
To use the Grails Events abstraction you should add a dependency on the `events` plugin to your `build.gradle` file:
6+
To use the Events abstraction you should add a dependency on the `events` plugin to your `build.gradle` file:
67

78
[source,groovy,subs="attributes"]
89
.build.gradle
910
----
10-
runtime "org.graceframework.plugins:events:{version}"
11+
implementation "org.graceframework.plugins:events:{version}"
1112
----
1213

13-
If no asynchronous framework in present on the classpath then by default Grails creates an EventBus based off of the currently active `PromiseFactory`. The default implementation is link:{api}/org/grails/async/factory/future/CachedThreadPoolPromiseFactory.html[CachedThreadPoolPromiseFactory] which uses a thread pool that will create threads as needed (the same as `java.util.concurrent.Executors.newCachedThreadPool()`).
14+
If no asynchronous framework in present on the classpath then by default Grace creates an EventBus based off of the currently active `PromiseFactory`.
15+
The default implementation is link:{api}/org/grails/async/factory/future/CachedThreadPoolPromiseFactory.html[CachedThreadPoolPromiseFactory] which uses a thread pool that will create threads as needed (the same as `java.util.concurrent.Executors.newCachedThreadPool()`).
1416

1517
If you wish to use a popular async framework such as RxJava as the `EventBus` implementation then you will need to add the appropriate dependency. For example for RxJava 1.x:
1618

1719
[source,groovy,subs="attributes"]
1820
.build.gradle
1921
----
20-
runtime "org.graceframework:grace-events-rxjava:{version}"
22+
implementation "org.graceframework:grace-events-rxjava:{version}"
2123
----
2224

2325
The following table summarizes async framework support and the necessary dependency:
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
With modern hardware featuring multiple cores, many programming languages have been adding asynchronous, parallel programming APIs, Groovy being no exception.
1+
This project contains APIs and libraries that integrate Grace with various asynchronous libraries and frameworks such as https://github.com/GPars/GPars[GPars] and https://github.com/ReactiveX/RxJava/tree/1.x[RxJava], https://github.com/ReactiveX/RxJava/releases/tag/v2.2.21[RxJava2], https://github.com/ReactiveX/RxJava/releases[RxJava3].
22

3-
Added Grails 2.3 and since 3.3 an external project, the Async features of Grails aim to simplify concurrent programming within the framework and include the concept of Promises and a unified event model.
3+
The Async framework aim to simplify concurrent programming within the framework and include the concept of Promises and a unified event model,
4+
and the Events framework provides a new Events API that replaces the previous implementation that was based on Reactor https://github.com/reactor/reactor/tree/v2.0.8.RELEASE[2.x] (which is no longer maintained and deprecated).

src/main/docs/guide/promises.adoc

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
A Promise is a concept being embraced by many concurrency frameworks. They are similar to `java.util.concurrent.Future` instances, but include a more user friendly exception handling model, useful features like chaining and the ability to attach listeners.
22

3-
To use the Grails Promise abstraction you should add a dependency on the `async` plugin to your `build.gradle` file:
3+
To use the `Promise` abstraction you should add a dependency on the `async` plugin to your `build.gradle` file:
44

55
[source,groovy,subs="attributes"]
66
.build.gradle
77
----
8-
runtime "org.graceframework.plugins:async:{version}"
8+
implementation "org.graceframework.plugins:async:{version}"
99
----
1010

1111
=== Promise Basics
1212

13-
14-
In Grails the `grails.async.Promises` class provides the entry point to the Promise API:
13+
The `grails.async.Promises` class provides the entry point to the Promise API:
1514

1615
[source,groovy]
1716
----
@@ -72,14 +71,16 @@ def result = p.get(1,MINUTES)
7271

7372
=== The PromiseFactory Interface
7473

75-
By default the `Promises` static methods use an instance of `PromiseFactory`. This `PromiseFactory` interface has various implementations. The default implementation is link:{api}/org/grails/async/factory/future/CachedThreadPoolPromiseFactory.html[CachedThreadPoolPromiseFactory] which uses a thread pool that will create threads as needed (the same as `java.util.concurrent.Executors.newCachedThreadPool()`)
74+
By default the `Promises` static methods use an instance of `PromiseFactory`. This `PromiseFactory` interface has various implementations.
75+
The default implementation is link:{api}/org/grails/async/factory/future/CachedThreadPoolPromiseFactory.html[CachedThreadPoolPromiseFactory] which uses a thread pool that will create threads as needed (the same as `java.util.concurrent.Executors.newCachedThreadPool()`)
7676

77-
However, the design of the Grails promises framework is such that you can swap out the underlying implementation for your own or one of the pre-supported implementations. For example to use RxJava 1.x simply add the RxJava dependency to `build.gradle`:
77+
However, the design of the promises framework is such that you can swap out the underlying implementation for your own or one of the pre-supported implementations.
78+
For example to use RxJava 1.x simply add the RxJava dependency to `build.gradle`:
7879

7980
[source,groovy,subs="attributes"]
8081
.build.gradle
8182
----
82-
runtime "org.graceframework:grace-async-rxjava:{version}"
83+
implementation "org.graceframework:grace-async-rxjava:{version}"
8384
----
8485

8586
With the above in place RxJava 1.x will be used to create `Promise` instances.
@@ -110,7 +111,8 @@ The following table summarizes the available implementation and the dependency t
110111
You can also override the `grails.async.PromiseFactory` class used by `Promises` by setting the `promiseFactory` static field.
111112

112113

113-
One common use case for this is unit testing, typically you do not want promises to execute asynchronously during unit tests, as this makes tests harder to write. For this purpose Grails ships with a `org.grails.async.factory.SynchronousPromiseFactory` instance that makes it easier to test promises:
114+
One common use case for this is unit testing, typically you do not want promises to execute asynchronously during unit tests, as this makes tests harder to write.
115+
For this purpose Grails ships with a `org.grails.async.factory.SynchronousPromiseFactory` instance that makes it easier to test promises:
114116

115117
[source,groovy]
116118
----
@@ -120,11 +122,11 @@ import grails.async.*
120122
Promises.promiseFactory = new SynchronousPromiseFactory()
121123
----
122124

123-
Using the `PromiseFactory` mechanism it is theoretically possible to plug in other concurrency libraries into the Grails framework. For this you need to override the two interfaces `grails.async.Promise` and `grails.async.PromiseFactory`.
125+
Using the `PromiseFactory` mechanism it is theoretically possible to plug in other concurrency libraries into the Grace framework.
126+
For this you need to override the two interfaces `grails.async.Promise` and `grails.async.PromiseFactory`.
124127

125128
=== Promise Chaining
126129

127-
128130
It is possible to chain several promises and wait for the chain to complete using the `then` method:
129131

130132
[source,groovy]
@@ -147,8 +149,7 @@ If an exception occurs at any point in the chain it will be propagated back to t
147149

148150
=== Promise Lists and Maps
149151

150-
151-
Grails' async API also features the concept of a promise lists and maps. These are represented by the `grails.async.PromiseList` and `grails.async.PromiseMap` classes respectively.
152+
The Async API also features the concept of a promise lists and maps. These are represented by the `grails.async.PromiseList` and `grails.async.PromiseMap` classes respectively.
152153

153154
The easiest way to create a promise list or map is via the `tasks` method of the `Promises` class:
154155

@@ -176,11 +177,10 @@ list.onComplete { List results ->
176177
}
177178
----
178179

179-
NOTE: The `PromiseList` class does not implement the java.util.List interface, but instead returns a java.util.List from the get() method
180+
NOTE: The `PromiseList` class does not implement the `java.util.List` interface, but instead returns a `java.util.List` from the `get()` method.
180181

181182
Working with `PromiseMap` instances is largely similar. Again you can either use the `tasks` method:
182183

183-
184184
[source,groovy]
185185
----
186186
import static grails.async.Promises.*
@@ -208,11 +208,10 @@ map.onComplete { Map results ->
208208
----
209209

210210

211-
212211
=== DelegateAsync Transformation
213212

214-
215-
It is quite common to require both synchronous and asynchronous versions of the same API. Developing both can result in a maintenance problem as typically the asynchronous API would simply delegate to the synchronous version.
213+
It is quite common to require both synchronous and asynchronous versions of the same API.
214+
Developing both can result in a maintenance problem as typically the asynchronous API would simply delegate to the synchronous version.
216215

217216
The `DelegateAsync` transformation is designed to mitigate this problem by transforming any synchronous API into an asynchronous one.
218217

src/main/docs/guide/releases.adoc

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
1-
[[releases]]
2-
== Release History
3-
41
To make it easier for users to use and upgrade, Plugin adopts a version policy consistent with the https://github.com/graceframework/grace-framework[Grace Framework].
52

6-
73
[cols="1,1"]
84
|===
95
| Plugin Version
106
| Grace Version
117

12-
| 6.3.x
8+
| link:{github}/tree/6.3.x[6.3.x]
139
| 2023.3.x
14-
| 6.2.x
10+
11+
| link:{github}/tree/6.2.x[6.2.x]
1512
| 2023.2.x
1613

17-
| 6.1.x
14+
| link:{github}/tree/6.1.x[6.1.x]
1815
| 2023.1.x
1916

20-
| 6.0.x
17+
| link:{github}/tree/6.0.x[6.0.x]
2118
| 2023.0.x
2219

23-
| 5.2.x
20+
| link:{github}/tree/5.2.x[5.2.x]
2421
| 2022.2.x
2522

26-
| 5.1.x
23+
| link:{github}/tree/5.1.x[5.1.x]
2724
| 2022.1.x
2825

29-
| 5.0.x
26+
| link:{github}/tree/5.0.x[5.0.x]
3027
| 2022.0.x
3128
|===

0 commit comments

Comments
 (0)