-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
225 lines (217 loc) · 8.08 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
---
layout: landing
index_page_title: Spine Event Engine
bodyclass: promo-page
---
<section id="landing-content" class="landing-content-container">
<div class="container-fluid content-holder justify-content-md-center">
<div class="row row-with-btn">
<div class="col-text">
<p class="step-title">Step 1.</p>
<h2 class="landing-row-title">Define rich, type‑safe domain model</h2>
<p>Describe commands, events, and state of entities using
<a href="https://developers.google.com/protocol-buffers/">Protobuf</a>.
</p>
</div>
<div class="col-btn">
<a class="code-toggle collapsed btn btn-bordered-blue"
href="#step-one"
data-toggle="collapse">
<span class="show-code">Show code</span>
<span class="hide-code">Hide code</span>
</a>
</div>
</div>
<div class="row justify-content-center collapse" id="step-one">
<div class="col-md-8">
{% highlight proto %}
// Create a new task.
message CreateTask {
TaskId id = 1; // assumed `required`
string name = 2 [(required) = true];
string description = 3;
}
{% endhighlight %}
</div>
<div class="col-md-8">
{% highlight proto %}
// A new task has been created.
message TaskCreated {
TaskId task = 1 [(required) = true];
string name = 2 [(required) = true];
string description = 3;
spine.core.UserId owner = 4 [(required) = true];
}
{% endhighlight %}
</div>
<div class="col-md-8">
{% highlight proto %}
// A task which can be assigned to a user.
message Task {
option (entity).kind = AGGREGATE;
TaskId id = 1; // assumed `required`
string name = 2 [(required) = true];
string description = 3;
spine.core.UserId owner = 4 [(required) = true];
spine.core.UserId assignee = 5;
}
{% endhighlight %}
<a class="hide-code-link"
href="#step-one"
data-toggle="collapse">Hide code</a>
</div>
</div>
<div class="row step-row">
<div class="col-md-12">
<p class="step-title">Step 2.</p>
<h2>Generate the data types code for all tiers and runtimes</h2>
</div>
</div>
<div class="row">
<div class="col-md-12">
<picture>
<source srcset="{{ site.baseurl }}/img/landing/generate-code.svg"
media="(min-width: 768px)">
<source srcset="{{ site.baseurl }}/img/landing/generate-code-mobile.svg">
<img class="landing-image no-shadow" alt="Generate code"
src="{{ site.baseurl }}/img/landing/generate-code.svg">
</picture>
</div>
</div>
<div class="row step-row row-with-btn">
<div class="col-text">
<p class="step-title">Step 3.</p>
<h2>Add business logic in a straight and testable way</h2>
<p>Focus on business logic rather than “plumbing”.
A <code>Command</code> will be delivered to only one <code>Aggregate</code>.
<code>Projection</code>s will get all <code>Event</code>s they need.
<code>ProcessManager</code>s will cover more complex scenarios. Storage,
message delivery, and other environment matters are isolated from the main code.
</p>
</div>
<div class="col-btn">
<a class="code-toggle collapsed btn btn-bordered-blue"
href="#step-three"
data-toggle="collapse">
<span class="show-code">Show code</span>
<span class="hide-code">Hide code</span>
</a>
</div>
</div>
<div class="row justify-content-center collapse" id="step-three">
<!--Aggregate code -->
<div class="col-md-8">
{% highlight java %}
final class TaskAggregate extends Aggregate<TaskId, Task, Task.Builder> {
@Assign
TaskCreated handle(CreateTask cmd, CommandContext ctx) {
return TaskCreated.newBuilder()
.setTask(cmd.getId())
.setName(cmd.getName())
.setDescription(cmd.getDescription())
.setOwner(ctx.getActorContext().getActor())
.vBuild(); // validate the event
}
@Apply
private void event(TaskCreated e) {
builder().setName(e.getName())
.setDescription(e.getDescription())
.setOwner(e.getOwner());
}
}
{% endhighlight %}
</div>
<!--Testing code -->
<div class="col-md-8">
{% highlight java %}
@DisplayName("Handling `CreateTask` command should")
public class TaskCreationTest extends ContextAwareTest {
private TaskId task;
private String name;
private String description;
...
@BeforeEach
void postCommand() {
CreateTask cmd = generateCommand();
context().receivesCommand(cmd);
}
@Test
@DisplayName("generate `TaskCreated` event")
void eventGenerated() {
TaskCreated expected = expectedEvent();
context().assertEvent(TaskCreated.class)
.comparingExpectedFieldsOnly()
.isEqualTo(expected);
}
@Test
@DisplayName("create a `Task`")
void aggregateCreation() {
Task expected = expectedAggregateState();
context().assertEntityWithState(task, Task.class)
.hasStateThat()
.comparingExpectedFieldsOnly()
.isEqualTo(expected);
}
}
{% endhighlight %}
<a class="hide-code-link"
href="#step-three"
data-toggle="collapse">Hide code</a>
</div>
</div>
<div class="row step-row row-with-btn">
<div class="col-text">
<p class="step-title">Step 4.</p>
<h2>Easily deploy to Google Cloud or a custom environment</h2>
<p>In-memory and JDBC-based storage implementations allow to implement and test
the core logic quickly. Adopt your application to selected deployment
environment(s) with a few lines of code.
</p>
</div>
<div class="col-btn">
<a class="code-toggle collapsed btn btn-bordered-blue"
href="#step-four"
data-toggle="collapse">
<span class="show-code">Show code</span>
<span class="hide-code">Hide code</span>
</a>
</div>
</div>
<div class="row justify-content-center collapse" id="step-four">
<!--Environment configuration code -->
<div class="col-md-8">
{% highlight java %}
static void configureEnvironment() {
StorageFactory rdbms = JdbcStorageFactory.newBuilder()
.setDataSource(dataSource())
.build();
StorageFactory datastore = DatastoreStorageFactory.newBuilder()
.setDatastore(datastoreService())
.build();
ServerEnvironment
.when(Production.class)
.use(datastore);
ServerEnvironment
.when(Tests.class)
.use(rdbms); // use RDBMS instead of default In-Memory storage for tests.
}
{% endhighlight %}
</div>
<!--Deploy command line -->
<div class="col-md-8">
{% highlight bash %}
./gradlew build deploy
{% endhighlight %}
<a class="hide-code-link"
href="#step-four"
data-toggle="collapse">Hide code</a>
</div>
</div>
</div>
</section>
<section id="landing-content-features" class="features-section">
<div class="container-fluid content-holder">
<h1 class="light section-title">Why Spine?</h1>
{% include feature-section.html %}
</div>
</section>