-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Blog posts service example: a direct-style vs monadic comparison | ||
|
||
## The need for a new `Future` construct | ||
|
||
The current implementation of the `Future` monadic construct suffers the following main cons: | ||
|
||
- Lack of **referential transparency** | ||
- Lack of **cancellation** mechanisms (and _structured concurrency_) | ||
- **Accidental Sequentiality** | ||
|
||
## Example: a blog posts service | ||
|
||
> **Idea**: develop a very simple (mocked) service which allows to store and retrive from a repository blog posts, as well as perform some checks before the actual storage. | ||
The example has been implemented using: | ||
|
||
- the current Scala `Future` constructs; | ||
- the mechanism abstractions offered by `gears`; | ||
- Kotlin. | ||
|
||
The sources are available in the `posts` package of both Kotlin and Scala main folders. | ||
|
||
### Structure | ||
|
||
#### Scala | ||
|
||
Uses Cake Pattern: | ||
|
||
- `PostsRepositoryComponent` | ||
- is the component exposing the `Repository` trait allowing to store and retrieve blog posts; | ||
- mocking a DB technology with an in-memory collection | ||
- `PostsServiceComponent` | ||
- is the component exposing the `Service` interface. | ||
|
||
Both the components must be designed in an async way. | ||
|
||
### 1st version: current Future monadic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
headless: true | ||
--- | ||
|
||
- [Boundary & Break]({{< relref "/docs/boundaries" >}}) | ||
- [Blog posts service example]({{< relref "/docs/blog-posts-service" >}}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters