Skip to content

Commit 09f93e6

Browse files
committed
docs: target system depencies
1 parent aa616f8 commit 09f93e6

File tree

9 files changed

+330
-224
lines changed

9 files changed

+330
-224
lines changed

docs/audit-stores/introduction.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ The audit store is **automatically provided and managed** by Flamingock Cloud. N
2727
Alternatively, you can configure your own audit store using one of the supported databases:
2828

2929
- [MongoDB audit store](./community/mongodb-audit-store.md)
30-
- [MongoDB Spring Data audit store](./community/mongodb-springdata-audit-store.md)
3130
- [DynamoDB audit store](./community/dynamodb-audit-store.md)
3231
- [Couchbase audit store](./community/couchbase-audit-store.md)
3332

docs/changes/anatomy-and-structure.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -176,23 +176,25 @@ public void rollback(MongoDatabase database, ClientSession session) {
176176

177177
## Method parameters and dependency injection
178178

179-
Changes receive dependencies through method parameters, automatically injected by Flamingock from the target system's context, global context, or underlying framework context.
179+
Changes receive dependencies through method parameters, automatically injected by Flamingock using a **flexible, multi-source approach** with fallback hierarchy.
180180

181-
```java
182-
// MongoDB target system
183-
@Apply
184-
public void apply(MongoDatabase database, ClientSession session) {
185-
// database and session injected from target system or global context
186-
}
181+
### Change Execution Dependency Resolution
187182

188-
// SQL target system
189-
@Apply
190-
public void apply(DataSource dataSource) {
191-
// dataSource and connection injected from target system or global context
192-
}
193-
```
183+
Change execution uses a flexible dependency resolution flow(in this priority order):
184+
185+
1. **Target system context** - dependencies from **constructor** + `.withXXX()` methods
186+
2. **Target system additional dependencies** - added via `.addDependency()` or `.setProperty()`
187+
3. **Global context** (fallback) - shared dependencies available to all target systems
188+
189+
190+
### Key Benefits of This Architecture
191+
192+
- **Target system isolation**: Each target system has its own dependency context
193+
- **Flexible fallback**: Changes can access both system-specific and shared dependencies
194+
- **Clear precedence**: Target system dependencies always override global ones
195+
- **Type safety**: Strongly typed dependency injection with compile-time checking
194196

195-
For more details on how dependency resolution works, see [Context and dependencies](../flamingock-library-config/context-and-dependencies.md).
197+
For complete details on target system configuration vs change execution dependencies, see [Target Systems Introduction](../target-systems/introduction.md#dependency-injection).
196198

197199
## File naming conventions
198200

docs/target-systems/couchbase-target-system.md

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,57 +7,65 @@ sidebar_position: 5
77

88
The Couchbase target system (`CouchbaseTargetSystem`) enables Flamingock to apply changes to Couchbase databases using the official Couchbase Java SDK. As a transactional target system, it supports automatic rollback through Couchbase's transaction capabilities.
99

10-
## Minimum recommended setup
10+
## Basic setup
1111

1212
```java
13-
CouchbaseTargetSystem couchbaseTarget = new CouchbaseTargetSystem("user-database")
14-
.withCluster(cluster)
15-
.withBucket(bucket);
13+
CouchbaseTargetSystem couchbaseTarget = new CouchbaseTargetSystem("user-database", cluster, bucket);
1614
```
1715

18-
While dependencies can be provided through the global context, we highly recommend injecting them directly at the target system level. This provides clearer scoping, better isolation between systems, and makes dependencies explicit and easier to track.
16+
The constructor requires the target system name, Couchbase cluster, and bucket. Optional configurations can be added via `.withXXX()` methods.
1917

20-
## Dependencies
18+
## Target System Configuration
2119

22-
Following Flamingock's [dependency resolution hierarchy](../flamingock-library-config/context-and-dependencies.md), you can provide dependencies via direct injection or global context.
20+
The Couchbase target system uses Flamingock's [split dependency resolution architecture](introduction.md#dependency-injection) with separate flows for target system configuration and change execution dependencies.
2321

24-
### Required dependencies
22+
### Constructor Dependencies (Mandatory)
2523

26-
| Dependency | Method | Description |
27-
|------------|--------|-------------|
28-
| `Cluster` | `.withCluster(cluster)` | Couchbase cluster connection - **required** for both Change execution and transaction management |
29-
| `Bucket` | `.withBucket(bucket)` | Target bucket instance - **required** for both Change execution and transaction management |
24+
These dependencies must be provided at target system creation time with **no global context fallback**:
3025

31-
Remember: If not provided directly via `.withXXX()`, Flamingock searches the global context. If still not found:
32-
- **Required dependencies** will throw an exception
26+
| Dependency | Constructor Parameter | Description |
27+
|------------|----------------------|-------------|
28+
| `Cluster` | `cluster` | Couchbase cluster connection - **required** for both target system configuration and change execution |
29+
| `Bucket` | `bucket` | Target bucket instance - **required** for both target system configuration and change execution |
30+
31+
### Dependencies Available to Changes
32+
33+
Changes can access dependencies through [dependency injection with fallback](../changes/anatomy-and-structure.md#method-parameters-and-dependency-injection):
34+
35+
1. **Target system context** (highest priority) - `Cluster`, `Bucket`, `AttemptContext`, plus any added via `.addDependency()`
36+
2. **Target system additional dependencies** - added via `.addDependency()` or `.setProperty()`
37+
3. **Global context** (fallback) - shared dependencies available to all target systems
3338

3439
## Configuration example
3540

36-
Here's a comprehensive example showing dependency resolution:
41+
Here's a comprehensive example showing the new architecture:
3742

3843
```java
39-
// Target system with specific dependencies
40-
CouchbaseTargetSystem couchbaseTarget = new CouchbaseTargetSystem("user-database")
41-
.withCluster(productionCluster) // Target-specific cluster
42-
.withBucket(userBucket) // Target-specific bucket
43-
.addDependency(auditService); // Custom service for this target
44+
// Target system configuration (mandatory via constructor)
45+
CouchbaseTargetSystem couchbaseTarget = new CouchbaseTargetSystem("user-database", productionCluster, userBucket)
46+
.addDependency(auditService); // Additional dependency for changes
4447

45-
// Global context with different dependencies
48+
// Global context with shared dependencies
4649
Flamingock.builder()
47-
.addDependency(defaultCluster) // Different cluster in global
48-
.addDependency(defaultBucket) // Different bucket in global
49-
.addDependency(emailService) // Available to all targets
50+
.addDependency(emailService) // Available to all target systems
51+
.addDependency(logService) // Available to all target systems
5052
.addTargetSystems(couchbaseTarget)
5153
.build();
5254
```
5355

54-
**What gets resolved for Changes in "user-database":**
55-
- **Cluster**: Uses `productionCluster` (from target system, not `defaultCluster` from global)
56-
- **Bucket**: Uses `userBucket` (from target system, not `defaultBucket` from global)
57-
- **AuditService**: Available from target system context
58-
- **EmailService**: Available from global context
56+
**Target system configuration resolution:**
57+
- **Cluster**: Must be provided via constructor (`productionCluster`)
58+
- **Bucket**: Must be provided via constructor (`userBucket`)
59+
60+
**Change dependency resolution for Changes in "user-database":**
61+
- **Cluster**: From target system context (`productionCluster`)
62+
- **Bucket**: From target system context (`userBucket`)
63+
- **AttemptContext**: From target system context (created by Flamingock)
64+
- **AuditService**: From target system additional dependencies
65+
- **EmailService**: From global context (fallback)
66+
- **LogService**: From global context (fallback)
5967

60-
The target system context always takes precedence, ensuring proper isolation between different systems.
68+
This architecture ensures explicit target system configuration while providing flexible dependency access for changes.
6169

6270
## Transactional support
6371

@@ -116,9 +124,9 @@ Without the `AttemptContext` parameter, operations will execute but won't partic
116124

117125
## Available dependencies in Changes
118126

119-
Your Changes can inject Couchbase-specific dependencies like `Cluster`, `Bucket`, and `AttemptContext` (for transactions), but are not limited to these. Any dependency can be added to the target system context via `.addDependency()`, taking precedence over global dependencies.
127+
Your Changes can inject Couchbase-specific dependencies like `Cluster`, `Bucket`, and `AttemptContext` (for transactions), but are not limited to these. The target system provides these dependencies through its context, and you can add additional dependencies via `.addDependency()` that take precedence over global dependencies.
120128

121-
For more details on dependency resolution, see [Context and dependencies](../flamingock-library-config/context-and-dependencies.md).
129+
For comprehensive details on change dependency resolution, see [Change Anatomy & Structure](../changes/anatomy-and-structure.md).
122130

123131
## Next steps
124132

docs/target-systems/default-target-system.md

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,61 +21,76 @@ DefaultTargetSystem is the fallback choice when there's no specialized target sy
2121

2222
**Common systems using DefaultTargetSystem:** Kafka Schema Registry, message queues, object storage (S3), REST APIs, file systems, cache systems, feature flags, search engines
2323

24-
## Minimum recommended setup
24+
## Basic setup
2525

2626
```java
2727
DefaultTargetSystem schemaRegistry = new DefaultTargetSystem("kafka-schema-registry");
2828
```
2929

30-
Unlike specialized target systems, DefaultTargetSystem requires no mandatory dependencies. You have complete flexibility to inject whatever dependencies your Changes need.
30+
Unlike specialized target systems, DefaultTargetSystem requires no mandatory constructor dependencies. You have complete flexibility to inject whatever dependencies your Changes need.
3131

32-
## Dependencies
32+
## Target System Configuration
3333

34-
Following Flamingock's [dependency resolution hierarchy](../flamingock-library-config/context-and-dependencies.md), you can provide dependencies via direct injection or global context.
34+
The Default target system uses Flamingock's [split dependency resolution architecture](introduction.md#dependency-injection) with separate flows for target system configuration and change execution dependencies.
3535

36-
### No required dependencies
36+
### Constructor Dependencies (None)
3737

38-
DefaultTargetSystem has no `.withXXX()` methods for required dependencies. This provides maximum flexibility for working with any type of system.
38+
Unlike specialized target systems, DefaultTargetSystem requires **no mandatory constructor dependencies**:
3939

40-
### Generic dependency injection
40+
```java
41+
// Only requires the target system name
42+
DefaultTargetSystem targetSystem = new DefaultTargetSystem("system-name");
43+
```
44+
45+
### Target System Configuration (Generic)
4146

42-
All dependencies are provided through generic methods:
47+
All dependencies and configurations are provided through generic methods with **no global context fallback** during target system configuration:
4348

4449
| Method | Description |
4550
|--------|-------------|
46-
| `.addDependency(object)` | Add a dependency by type |
47-
| `.addDependency(name, object)` | Add a named dependency |
48-
| `.setProperty(key, value)` | Set a configuration property |
51+
| `.addDependency(object)` | Add a dependency by type for changes |
52+
| `.addDependency(name, object)` | Add a named dependency for changes |
53+
| `.setProperty(key, value)` | Set a configuration property for changes |
4954

50-
Remember: If not provided directly, Flamingock searches the global context for dependencies.
55+
### Dependencies Available to Changes
56+
57+
Changes can access dependencies through [dependency injection with fallback](../changes/anatomy-and-structure.md#method-parameters-and-dependency-injection):
58+
59+
1. **Target system context** (highest priority) - any dependencies added via `.addDependency()` or properties via `.setProperty()`
60+
2. **Global context** (fallback) - shared dependencies available to all target systems
5161

5262
## Configuration example
5363

54-
Here's a comprehensive example showing dependency resolution:
64+
Here's a comprehensive example showing the new architecture:
5565

5666
```java
57-
// Target system with Kafka Schema Registry dependencies
67+
// Target system configuration (no mandatory constructor dependencies)
5868
DefaultTargetSystem schemaRegistry = new DefaultTargetSystem("kafka-schema-registry")
59-
.addDependency(schemaRegistryClient)
60-
.addDependency("registry-url", "http://schema-registry:8081")
61-
.setProperty("compatibility.level", "BACKWARD");
69+
.addDependency(schemaRegistryClient) // Additional dependency for changes
70+
.addDependency("registry-url", "http://schema-registry:8081") // Named dependency
71+
.setProperty("compatibility.level", "BACKWARD"); // Configuration property
6272

6373
// Global context with shared dependencies
6474
Flamingock.builder()
65-
.addDependency(metricsService) // Available to all targets
66-
.addDependency(notificationService) // Available to all targets
75+
.addDependency(metricsService) // Available to all target systems
76+
.addDependency(notificationService) // Available to all target systems
6777
.addTargetSystems(schemaRegistry)
6878
.build();
6979
```
7080

71-
**What gets resolved for Changes in "kafka-schema-registry":**
72-
- **SchemaRegistryClient**: Available from target system context
73-
- **Registry URL**: Available as "registry-url" from target system context
74-
- **Compatibility level**: Available as property from target system context
75-
- **MetricsService**: Available from global context
76-
- **NotificationService**: Available from global context
81+
**Target system configuration resolution:**
82+
- **No mandatory dependencies**: Target system created with name only
83+
- **Additional dependencies**: Added via `.addDependency()` methods
84+
- **Configuration properties**: Added via `.setProperty()` method
85+
86+
**Change dependency resolution for Changes in "kafka-schema-registry":**
87+
- **SchemaRegistryClient**: From target system additional dependencies
88+
- **Registry URL**: From target system context as named dependency ("registry-url")
89+
- **Compatibility level**: From target system context as property ("compatibility.level")
90+
- **MetricsService**: From global context (fallback)
91+
- **NotificationService**: From global context (fallback)
7792

78-
The target system context always takes precedence, ensuring proper isolation between different systems.
93+
This architecture provides maximum flexibility while maintaining clear separation between target system setup and change execution.
7994

8095
**How compensation works:**
8196
1. **No transaction boundaries**: Operations execute immediately with no automatic rollback
@@ -86,9 +101,9 @@ The target system context always takes precedence, ensuring proper isolation bet
86101

87102
## Available dependencies in Changes
88103

89-
Your Changes can inject any dependencies you add to the target system context via `.addDependency()`, taking precedence over global dependencies. Common examples include system clients, configuration values, custom services, and properties.
104+
Your Changes can inject any dependencies you add to the target system context via `.addDependency()` or properties via `.setProperty()`, which take precedence over global dependencies. Common examples include system clients, configuration values, custom services, and properties.
90105

91-
For more details on dependency resolution, see [Context and dependencies](../flamingock-library-config/context-and-dependencies.md).
106+
For comprehensive details on change dependency resolution, see [Change Anatomy & Structure](../changes/anatomy-and-structure.md).
92107

93108
## Next steps
94109

0 commit comments

Comments
 (0)