Skip to content

Commit b9ccc78

Browse files
committed
⬆️ Upgrade to 1.0
1 parent 16524e8 commit b9ccc78

File tree

3 files changed

+47
-56
lines changed

3 files changed

+47
-56
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2018 Jérémy Marodon
3+
Copyright (c) 2018-2020 Jérémy Marodon
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+45-54
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,51 @@ This repository is the scaffold of the Thunder CLI micro-framework.
1111
You can use it and modify the structure to adapt on your needs.
1212

1313
## Philosophy
14-
Sometimes you just need a very simple deamon, eventloop based, when you're event programming.
15-
A small repository for your boundary, with few dependencies, and don't want to
14+
Sometimes you just need a very simple deamon, eventloop based, when you're event programming.
15+
A small repository for your boundary, with few dependencies, and don't want to
1616
be force to use a library or an other.
1717

18-
All you need is a reaction to an event that has been occurred in your system,
18+
All you need is a reaction to an event that has been occurred in your system,
1919
externally or internally (pub/sub or saga f.e.).
2020

21-
However, this project is born inside a repository using Reactive Programming
22-
by default, RabbitMQ consumers, a router, EventStore projections and events,
21+
However, this project is born inside a repository using Reactive Programming
22+
by default, RabbitMQ consumers, a router, EventStore projections and events,
2323
mysql, Redis connectors, and many more.
2424

2525
Simple but powerful.
2626

2727
## What built in
2828
### Console Component
29-
The whole concept is base on consoles.
29+
The whole concept is based on consoles.
3030
Instead of reinvent the wheel, Thunder use [Silly](https://github.com/mnapoli/silly)
31-
micro-framework. An `AbstractConsole` is provided by the framework, allowing
32-
classes extending it to be automatically loaded and usable.
31+
micro-framework. A `Console` class being provided by the framework, allowing
32+
classes that extend it to be automatically loaded and usable.
3333

3434
### Dependency Injection
35-
Usage of the dependency injection pattern, ease decoupling your code and quality
35+
Usage of the dependency injection pattern, ease decoupling your code and quality
3636
test writing. [Symfony DI](https://symfony.com/doc/current/components/dependency_injection.html)
3737
component has been chosen for it many features [](https://symfony.com/doc/current/components/dependency_injection.html#learn-more)
38-
improving developer experience.
38+
improving developer experience.
3939

4040
### Configuration Component
41-
This component allows you to use XML, YAML & PHP files. You can access and use
41+
This component allows you to use XML, YAML & PHP files. You can access and use
4242
them directly into constructors through DI.
4343

4444
### Router
45-
This component is central in the project, Command Bus and Event Dispatcher
45+
This component is central in the project, Command Bus and Event Dispatcher
4646
pattern aren't adapted to non acknowledge (`nack`) messages.
4747

48-
It force to use [Subjects](http://reactivex.io/documentation/subject.html) in cases
49-
where `ack/nack` is necessary on the message.
48+
It's pretty straight forward, a `Route` can be associated to a `Controller` in a
49+
MVC schema. The core provide a base class called `Route` that allow to
50+
automatically load all classes extending it in the `Router`.
5051

51-
It needs some `AbstractRoute` and send an `AbstractSubject` to the right one.
52-
An `AbstractRoute` can be associated to a `Controller` in traditional software
53-
architecture pattern.
52+
Each route have to define it's constant called `PATH`. It's used to determine
53+
which `Route` of your application must be invoked.
54+
55+
As we are in an event driven framework, all `Route` must return an `Observable`.
56+
The different plugins that you will use in your application, are subscribing to
57+
your `Observable` using `Observers` to determine actions to execute at the end
58+
of your event chain.
5459

5560
## Installation
5661

@@ -65,31 +70,24 @@ To start the project you need to execute a PHP file available in the vendors, `v
6570

6671
All commands available will be prompted.
6772

68-
### Subject
69-
When your are consuming a source of data, each message is converted into an
70-
`AbstractSubject`. This subject is an `Observable` & an `Observer` with some
71-
subscribers already plugged.
72-
73-
One of the subscribers is responsible to handle the `acknowledge/non-acknowledge` behavior.
74-
75-
So basically, when the subject is completed, the message is acknowledged, and
76-
you will received a new message when available.
77-
7873
### Create a new Route
79-
Just extends the `Th3Mouk\Thunder\Route\AbstractRoute` into `/src` and it will
74+
Create a class extending `Th3Mouk\Thunder\Router\Route` into `/src` and it will
8075
be automatically added to the router.
8176

82-
You can modify the `config/services.php` and `composer.json` autoload if you
77+
You can modify the `config/services.php` and `composer.json` autoload if you
8378
don't want to use `src` folder.
8479

80+
Your `Route` will now be invoked with the corresponding `DataModel` through
81+
the PATH constant.
82+
8583
#### Extra: Handler concept
8684
I personally use `src/route` and `src/handler` structure.
8785
The term `handler` coming from the Command Bus pattern.
8886

89-
An handler here, is a small invokable unit that can be reused in multiple
87+
An handler here, is a small invokable unit that can be reused in multiple
9088
contexts, sagas of events, or here again routes.
91-
The main advantage of this, is you can decouple your code and test it correctly,
92-
because yes, this handler will be automatically injected in the container,
89+
The main advantage of this, is you can decouple your code and test it correctly,
90+
because yes, this handler will be automatically injected in the container,
9391
and you can use DI in its constructor :tada:.
9492

9593
An example can be:
@@ -98,13 +96,13 @@ An example can be:
9896
namespace App\Handler;
9997

10098
use Rx\Observable;
101-
use Th3Mouk\Thunder\Router\AbstractSubject;
99+
use RxThunder\Core\Model\DataModel;
102100

103101
class PromptHello
104102
{
105-
public function __invoke(AbstractSubject $subject)
103+
public function __invoke(DataModel $data_model)
106104
{
107-
return Observable::of($subject)
105+
return Observable::of($data_model)
108106
->do(function() {
109107
echo "hello there". PHP_EOL;
110108
});
@@ -120,10 +118,10 @@ namespace App\Route;
120118

121119
use App\Handler\PromptHello;
122120
use Rx\Observable;
123-
use Th3Mouk\Thunder\Router\AbstractRoute;
124-
use Th3Mouk\Thunder\Router\AbstractSubject;
121+
use RxThunder\Core\Model\DataModel;
122+
use RxThunder\Core\Router\Route;
125123

126-
class Test extends AbstractRoute
124+
class Test extends Route
127125
{
128126
public const PATH = '/test';
129127

@@ -135,34 +133,27 @@ class Test extends AbstractRoute
135133
$this->prompt = $prompt;
136134
}
137135

138-
public function __invoke(AbstractSubject $subject)
136+
public function __invoke(DataModel $data_model): Observable
139137
{
140-
return Observable::of($subject)
138+
return Observable::of($data_model)
141139
->do(function () {
142140
echo "i'm in /test".PHP_EOL;
143141
})
144142
->flatMap($this->prompt)
145143
->do(function () {
146144
echo "passed in /test".PHP_EOL;
147-
})
148-
->subscribe(function (AbstractSubject $subject) {
149-
$subject->onCompleted();
150145
});
151146
}
152147
}
153148
```
154149

155150
### Start consuming
156-
If you use the RabbitMq consumer you can start with `php console listen:broker:rabbit test default`
157-
`test` is the name of the queue to consume
158-
`default` is the name of the connection to use
159-
160-
The connection system and configuration of RabbitMq is not documented yet and
161-
probably will be extracted into a plug & play plugin.
151+
If you use the RabbitMQ plugin you can start consuming a queue with
152+
`php console rabbit:listen:broker test`
153+
(`test` is the name of the queue to consume)
162154

163-
Each message received by the queue will be transformed into a `RabbitMq/Subject`
164-
and the **routing key** is the pattern the router is looking into the collection
165-
of routes.
155+
Each message received by the queue will be transformed into a `DataModel`
156+
and the **routing key** correspond to the `type()` of it.
166157

167-
For example a message with `/test` routing key in Rabbit will be consumed by
168-
the route with `public const PATH = '/test';`
158+
For example a message with `/test` routing key in RabbitMQ will be consumed by
159+
the route with `public const PATH = '/test';`

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
],
1212
"require": {
13-
"rxthunder/core": "^0.6.0"
13+
"rxthunder/core": "^1.0"
1414
},
1515
"autoload": {
1616
"psr-4": {

0 commit comments

Comments
 (0)