Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#49 node factories with common configs #62

Merged
merged 81 commits into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
47847f6
Default task provider
tomaszmichalak Nov 8, 2019
edbca6a
Task factories refactor.
tomaszmichalak Nov 8, 2019
10e0a35
Test class rename.
tomaszmichalak Nov 8, 2019
427f508
Task factory with cacheable action provider.
tomaszmichalak Nov 13, 2019
c1fde29
Readme updates.
tomaszmichalak Nov 13, 2019
69bbd84
Documentation update.
tomaszmichalak Nov 14, 2019
775f121
Extract node factories.
tomaszmichalak Nov 14, 2019
6f4e045
Factories as service providers
tomaszmichalak Nov 14, 2019
7ed4942
Factories as service providers
tomaszmichalak Nov 14, 2019
09a01ce
Extract node provider interface
tomaszmichalak Nov 14, 2019
eff0c9f
Node factories contract fixes, no action config dependency.
tomaszmichalak Nov 15, 2019
6edbd26
Add missing factories
tomaszmichalak Nov 18, 2019
7a2bc73
Fix comments
tomaszmichalak Nov 18, 2019
56d7ef0
Changing configuration model
tomaszmichalak Nov 19, 2019
3a4d896
Fixing tests
tomaszmichalak Nov 19, 2019
6a4a7e3
Unit tests fixes
tomaszmichalak Nov 21, 2019
cd49061
Introduce model for fragments handler
tomaszmichalak Nov 21, 2019
789837c
Fragments handler tests cleanup.
tomaszmichalak Nov 21, 2019
e9a26c9
Node factories
tomaszmichalak Nov 21, 2019
6e04728
Cleanup task options and remove task context from node creation.
tomaszmichalak Nov 22, 2019
2f390a1
Move tests to ActionNodeFactoryTest
tomaszmichalak Nov 22, 2019
80775ff
Add tests for subtasks node factory
tomaszmichalak Nov 22, 2019
b2f8e4c
Exceptions cleanup
tomaszmichalak Nov 25, 2019
6f9cb5a
Added logging during tasks creation, small fixes.
tomaszmichalak Nov 25, 2019
aed3ec9
Tests cleanup.
tomaszmichalak Nov 25, 2019
66c6caa
TaskOptionsTest cleanup, added tests for log level.
tomaszmichalak Nov 25, 2019
6fb6e4b
CR: remove TaskOptions, skip one additional graph configuration entry.
tomaszmichalak Nov 26, 2019
c8a3878
Rename ActionOptions to ActionFactoryOptions.
tomaszmichalak Nov 26, 2019
c48d8a9
README updates
tomaszmichalak Nov 26, 2019
8519da3
Apply suggestions from code review
tomaszmichalak Nov 26, 2019
bda5642
Default task factory accepts only configured tasks.
tomaszmichalak Nov 26, 2019
e408ba7
Merge branch 'feature/#49-node-factories-with-common-configs' of gith…
tomaszmichalak Nov 26, 2019
565fdaf
CR fixes
tomaszmichalak Nov 26, 2019
3bb8291
Add TaskFactory javadocs.
tomaszmichalak Nov 26, 2019
2a8c37d
Javadocs & ascidocs.
tomaszmichalak Nov 26, 2019
ca26b13
Javadocs.
tomaszmichalak Nov 26, 2019
6d7b86f
Javadocs
tomaszmichalak Nov 26, 2019
fca85e2
Apply suggestions from code review: README updates.
tomaszmichalak Nov 26, 2019
44b43e8
Merge with master
tomaszmichalak Nov 27, 2019
c7d5516
Merge branch 'feature/#49-node-factories-with-common-configs' of gith…
tomaszmichalak Nov 27, 2019
30cad76
Merge with master
tomaszmichalak Nov 27, 2019
39d2412
Default task provider
tomaszmichalak Nov 8, 2019
b2e1572
Task factories refactor.
tomaszmichalak Nov 8, 2019
0afbd8b
Test class rename.
tomaszmichalak Nov 8, 2019
a1a2f27
Task factory with cacheable action provider.
tomaszmichalak Nov 13, 2019
43be617
Readme updates.
tomaszmichalak Nov 13, 2019
355e92e
Documentation update.
tomaszmichalak Nov 14, 2019
495ceb0
Extract node factories.
tomaszmichalak Nov 14, 2019
46d3a60
Factories as service providers
tomaszmichalak Nov 14, 2019
ded49ff
Factories as service providers
tomaszmichalak Nov 14, 2019
8665ee5
Extract node provider interface
tomaszmichalak Nov 14, 2019
25b4b2b
Node factories contract fixes, no action config dependency.
tomaszmichalak Nov 15, 2019
e2c61ce
Add missing factories
tomaszmichalak Nov 18, 2019
03375a8
Fix comments
tomaszmichalak Nov 18, 2019
a6d2aed
Changing configuration model
tomaszmichalak Nov 19, 2019
cf96336
Fixing tests
tomaszmichalak Nov 19, 2019
5a8d12b
Unit tests fixes
tomaszmichalak Nov 21, 2019
9e3868b
Introduce model for fragments handler
tomaszmichalak Nov 21, 2019
8ae5876
Fragments handler tests cleanup.
tomaszmichalak Nov 21, 2019
5521bc9
Node factories
tomaszmichalak Nov 21, 2019
c536eb7
Cleanup task options and remove task context from node creation.
tomaszmichalak Nov 22, 2019
a3e3405
Move tests to ActionNodeFactoryTest
tomaszmichalak Nov 22, 2019
ebd4d4c
Add tests for subtasks node factory
tomaszmichalak Nov 22, 2019
9a94fd9
Exceptions cleanup
tomaszmichalak Nov 25, 2019
ef0bce2
Added logging during tasks creation, small fixes.
tomaszmichalak Nov 25, 2019
fe1c2f9
Tests cleanup.
tomaszmichalak Nov 25, 2019
accdc0f
TaskOptionsTest cleanup, added tests for log level.
tomaszmichalak Nov 25, 2019
0953725
CR: remove TaskOptions, skip one additional graph configuration entry.
tomaszmichalak Nov 26, 2019
43fb309
Rename ActionOptions to ActionFactoryOptions.
tomaszmichalak Nov 26, 2019
442339a
README updates
tomaszmichalak Nov 26, 2019
f4807d7
Apply suggestions from code review
tomaszmichalak Nov 26, 2019
9cb5a37
Default task factory accepts only configured tasks.
tomaszmichalak Nov 26, 2019
855b341
CR fixes
tomaszmichalak Nov 26, 2019
acc8ceb
Add TaskFactory javadocs.
tomaszmichalak Nov 26, 2019
eb71a8c
Javadocs & ascidocs.
tomaszmichalak Nov 26, 2019
ffaf36c
Javadocs.
tomaszmichalak Nov 26, 2019
444e8ab
Javadocs
tomaszmichalak Nov 26, 2019
b4d1336
Apply suggestions from code review: README updates.
tomaszmichalak Nov 26, 2019
742bc19
Merge with master
tomaszmichalak Nov 27, 2019
934022f
Merge branch 'feature/#49-node-factories-with-common-configs' of gith…
tomaszmichalak Nov 28, 2019
aa95398
Trigger Azure build
tomaszmichalak Nov 28, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
# Generated files #
###################
node_modules
node
target-grunt
.sass-cache
.grunt
C:
.project
.classpath
.settings
generated

# Compiled source #
###################
# *.com
*.class
*.dll
*.exe
*.o
*.so

# Packages #
############
Expand All @@ -39,8 +28,6 @@ generated
# Logs and databases #
######################
*.log
*.sql
*.sqlite

# OS generated files #
######################
Expand Down
285 changes: 151 additions & 134 deletions handler/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public enum ActionLogLevel {
INFO("info"), ERROR("error");

public static final String CONFIG_KEY_NAME = "logLevel";

private final String level;

ActionLogLevel(String level) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
*/
package io.knotx.fragments.handler.api.actionlog;

import static io.knotx.fragments.handler.api.actionlog.ActionLogLevel.CONFIG_KEY_NAME;
import static io.knotx.fragments.handler.api.actionlog.ActionLogLevel.INFO;

import io.vertx.core.json.JsonObject;
import java.time.Instant;
import java.util.Objects;
import java.util.function.Function;

import io.vertx.core.json.JsonObject;

public class ActionLogger {

private final ActionLogLevel actionLogLevel;
Expand All @@ -34,10 +32,6 @@ private ActionLogger(String alias, ActionLogLevel actionLogLevel) {
this.builder = new ActionLogBuilder(alias);
}

public static ActionLogger create(String alias, JsonObject config) {
return ActionLogger.create(alias, config.getString(CONFIG_KEY_NAME));
}

public static ActionLogger create(String alias, ActionLogLevel actionLogLevel) {
return new ActionLogger(alias, actionLogLevel);
}
Expand Down
183 changes: 110 additions & 73 deletions handler/core/docs/asciidoc/dataobjects.adoc
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
= Cheatsheets

[[ActionNodeConfigOptions]]
== ActionNodeConfigOptions
[[ActionFactoryOptions]]
== ActionFactoryOptions


[cols=">25%,25%,50%"]
[frame="topbot"]
|===
^|Name | Type ^| Description
|[[config]]`@config`|`Json object`|+++
Sets <code>Action</code> configuration that is passed to Action.
+++
|[[doAction]]`@doAction`|`String`|+++
Sets the name of the base <code>Action</code> that will be triggered while creating current <code>Action</code>. In not set (<code>null</code>), given action will have no base actions.
+++
|[[factory]]`@factory`|`String`|+++
Sets <code>Action</code> factory name.
+++
|===

[[ActionNodeConfig]]
== ActionNodeConfig

++++
Action node configuration model. It is model for link JSON object.
Action node configuration model. It is model for JSON object.

<pre>
node {
factory = action
config { //represented by ActionNodeConfigOptions
config { //represented by ActionNodeConfig
...
}
}
Expand All @@ -27,74 +46,73 @@ Sets link name. The specified Action is executed
+++
|===

[[ActionOptions]]
== ActionOptions
[[ActionNodeFactoryConfig]]
== ActionNodeFactoryConfig

++++
Action Node factory config model.
++++
'''

[cols=">25%,25%,50%"]
[frame="topbot"]
|===
^|Name | Type ^| Description
|[[config]]`@config`|`Json object`|+++
Sets <code>Action</code> configuration that is passed to Action.
|[[actions]]`@actions`|`link:dataobjects.html#ActionFactoryOptions[ActionFactoryOptions]`|+++
The dictionary maps action name to action factory options.
+++
|[[doAction]]`@doAction`|`String`|+++
Sets the name of the base <code>Action</code> that will be triggered while creating current <code>Action</code>. In not set (<code>null</code>), given action will have no base actions.
|===

[[DefaultTaskFactoryConfig]]
== DefaultTaskFactoryConfig

++++
Default Task Factory config model.
++++
'''

[cols=">25%,25%,50%"]
[frame="topbot"]
|===
^|Name | Type ^| Description
|[[logLevel]]`@logLevel`|`String`|+++
The global node log level.
+++
|[[factory]]`@factory`|`String`|+++
Sets <code>Action</code> factory name.
|[[nodeFactories]]`@nodeFactories`|`Array of link:dataobjects.html#NodeFactoryOptions[NodeFactoryOptions]`|+++
The array/list of graph node factory options defines node factories taking part in the creation
of graph.
+++
|[[taskNameKey]]`@taskNameKey`|`String`|+++
The fragment's configuration key specifies a task assigned to a fragment by the task name.
+++
|[[tasks]]`@tasks`|`link:dataobjects.html#GraphNodeOptions[GraphNodeOptions]`|+++
The dictionary that maps a task name to a directed acyclic graph (DAG) of nodes.
+++
|===

[[FragmentsHandlerOptions]]
== FragmentsHandlerOptions

++++
Fragments Handler options model.
++++
'''

[cols=">25%,25%,50%"]
[frame="topbot"]
|===
^|Name | Type ^| Description
|[[actions]]`@actions`|`link:dataobjects.html#ActionOptions[ActionOptions]`|+++
Sets named actions with their factory configuration.
+++
|[[logLevel]]`@logLevel`|`String`|-
|[[taskKey]]`@taskKey`|`String`|-
|[[tasks]]`@tasks`|`link:dataobjects.html#TaskOptions[TaskOptions]`|+++
Sets <code>Task</code> list, which are named, directed graphs of <code>Actions</code>.
|[[taskFactories]]`@taskFactories`|`Array of link:dataobjects.html#TaskFactoryOptions[TaskFactoryOptions]`|+++
The array/list of task factory options defines factories taking part in the creation of tasks. First
items on the list have the highest priority.
+++
|===

[[GraphNodeOptions]]
== GraphNodeOptions

++++
It is link processing configuration. Task is graph of nodes (in
fact it is tree structure). It defines link and outgoing directed graph edges,
called <code>Transitions</code>.

It represents JSON configuration:
<pre>
{
node = {
factory = action
config {
action = a
}
}
onTransitions {
_success {
node = {
factory = action
config {
action = b
}
}
}
}
}
</pre>

Please note that Transitions define next graph nodes.
Graph node options model.
++++
'''

Expand All @@ -103,20 +121,51 @@ Sets <code>Task</code> list, which are named, directed graphs of <code>Actions</
|===
^|Name | Type ^| Description
|[[action]]`@action`|`String`|+++

Sets a node factory name to <code>ActionNodeFactory.NAME</code> and configures the action.
+++
|[[actions]]`@actions`|`Array of link:dataobjects.html#GraphNodeOptions[GraphNodeOptions]`|+++

Sets a node factory name to <code>SubtasksNodeFactory.NAME</code> and configures subgraphs.
+++
|[[composite]]`@composite`|`Boolean`|-
|[[node]]`@node`|`link:dataobjects.html#NodeOptions[NodeOptions]`|+++
Sets node options defining node factory and its configuration.
Node options define a node factory and its configuration.
+++
|[[onTransitions]]`@onTransitions`|`link:dataobjects.html#GraphNodeOptions[GraphNodeOptions]`|+++
Sets outgoing graph node edges, called <code>Transitions</code>. Transition is String, <code>onTransitions</code> map links Transition with next graph node.
The outgoing graph node edges, called transitions. A transition is named graph edge that
defines the next graph node in fragment's processing.
+++
|[[subtasks]]`@subtasks`|`Array of link:dataobjects.html#GraphNodeOptions[GraphNodeOptions]`|+++
Sets a node factory name to <code>SubtasksNodeFactory.NAME</code> and configures subgraphs.
+++
|===

[[LogLevelConfig]]
== LogLevelConfig


[cols=">25%,25%,50%"]
[frame="topbot"]
|===
^|Name | Type ^| Description
|[[logLevel]]`@logLevel`|`String`|-
|===

[[NodeFactoryOptions]]
== NodeFactoryOptions

++++
Node Factory options model.
++++
'''

[cols=">25%,25%,50%"]
[frame="topbot"]
|===
^|Name | Type ^| Description
|[[config]]`@config`|`Json object`|+++
The JSON object that contains node factory configuration entries.
+++
|[[factory]]`@factory`|`String`|+++
The node factory name that identifies <code>NodeFactory</code> implementation.
+++
|===

Expand All @@ -140,20 +189,11 @@ Sets node factory name
+++
|===

[[SubtasksNodeConfigOptions]]
== SubtasksNodeConfigOptions
[[SubtasksNodeConfig]]
== SubtasksNodeConfig

++++
Subtask node configuration. It is model for link JSON object.

<pre>
node {
factory = subtasks
config { //represented by SubtasksNodeConfigOptions
...
}
}
</pre>
Subtask Node configuration.
++++
'''

Expand All @@ -162,16 +202,16 @@ Sets node factory name
|===
^|Name | Type ^| Description
|[[subtasks]]`@subtasks`|`Array of link:dataobjects.html#GraphNodeOptions[GraphNodeOptions]`|+++
Sets list of link that represents link
that will be executed in parallel.
The array/list of subgraphs/subtasks that can be executed in parallel.
+++
|===

[[TaskOptions]]
== TaskOptions
[[TaskFactoryOptions]]
== TaskFactoryOptions

++++
Task options.
Task Factory options model. It specifies task factory by its name and provides task factory
config.
++++
'''

Expand All @@ -180,13 +220,10 @@ Sets list of link that represents link
|===
^|Name | Type ^| Description
|[[config]]`@config`|`Json object`|+++
Gets task provider factory configuration.
The JSON object that contains task factory configuration entries.
+++
|[[factory]]`@factory`|`String`|+++
Sets task provider factory name
+++
|[[graph]]`@graph`|`link:dataobjects.html#GraphNodeOptions[GraphNodeOptions]`|+++
Sets task graph.
The task factory name that identifies <code>TaskFactory</code> implementation.
+++
|===

27 changes: 27 additions & 0 deletions handler/core/handler/common/customTask.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
tasks {
success-task {
graph {
action = success-action
}
}
}

nodeFactories = [
{
factory = action
config {
actions {
success-action {
factory = test-action
config {
transition = _success
body = "custom"
}
}
}
}
}
{
factory = subtasks
}
]
Loading