Service Runtime
Relevant source files
The following files were used as context for generating this wiki page:
The Service Runtime provides internal runtime adapters and infrastructure to facilitate the operation of the LDAP target within the Singer/Meltano ecosystem. It acts as a bridge between high-level Singer target interfaces and the specific LDAP implementation logic, ensuring that data records are correctly processed, validated, and transformed before being sent to the target LDAP directory.
Sources: src/flext_target_ldap/_utilities/service_runtime.py:1-10, src/flext_target_ldap/api.py:13-25
Architecture and Components
The service runtime is centered around the FlextTargetLdapServiceRuntime class, which manages the lifecycle and adaptation of Singer-compatible components. It utilizes nested adapter classes to satisfy the requirements of the flext-meltano framework while delegating actual data operations to specialized LDAP sinks.
Core Runtime Components
| Component | Description |
|---|---|
FlextTargetLdapServiceRuntime | The primary facade for creating and managing service-level adapters. |
ServiceRuntime.Target | A minimal implementation of Meltano.SingerTargetBase used to identify the service. |
ServiceRuntime.Sink | An adapter sink that overrides standard Singer hooks to delegate to the LDAP runtime. |
FlextTargetLdapSink | The specialized LDAP-aware sink that performs the actual record processing. |
Sources: src/flext_target_ldap/_utilities/service_runtime.py:13-33, src/flext_target_ldap/api.py:40-60
Component Relationship Diagram
The following diagram illustrates how the Service Runtime adapters wrap the core LDAP target logic to provide a Singer-compatible interface.
Data Flow and Record Processing
The Service Runtime manages the transition of data from the Singer input stream into the LDAP-specific sink implementation. This involves normalization of schemas and the delegation of record handling.
Record Handling Logic
When a record is received, the ServiceRuntime.Sink intercepts the process_record call. It normalizes the record and context into standard JSON mappings before passing them to the internal _runtime_sink. If the runtime sink returns a failure result, the runtime raises a RuntimeError to signal a fatal processing issue.
Schema Normalization
Before a sink is instantiated, the runtime performs "flat schema normalization". This process ensures that complex types (like pathlib.Path objects) are converted into JSON-compatible strings using utility methods from the flext_meltano and flext_cli packages.
Sources: src/flext_target_ldap/_utilities/service_runtime.py:89-98, src/flext_target_ldap/settings.py:33-45
Sink Creation and Configuration
The create_sink method is the entry point for generating the necessary infrastructure for a specific data stream (e.g., "users" or "groups").
- Configuration Normalization: The target configuration is normalized to a standard JSON mapping.
- Target Initialization: A
FlextTargetLdapinstance is created with the provided configuration. - Sink Class Selection: The runtime determines the appropriate sink class (e.g.,
UsersSink) based on thestream_name. - Adapter Assembly: The runtime-specific sink is wrapped in the
ServiceRuntime.Sinkadapter.
Domain Models and Validation
The Service Runtime relies on the domain models defined in FlextTargetLdapModels to ensure data integrity. These models provide structured representations for LDAP entries and transformation rules.
LDAP Entry Model
The Entry model within the TargetLdap domain defines the requirements for a valid LDAP object.
| Field | Type | Description |
|---|---|---|
distinguished_name | NonEmptyStr | The unique LDAP DN for the entry. |
object_classes | MutableSequence[str] | List of object classes; automatically includes "top". |
attributes | Mapping | Key-value pairs of LDAP attributes. |
entry_type | str | Type (e.g., user, group, ou). |
Sources: src/flext_target_ldap/models.py:84-118
Transformation Rules
The runtime supports data transformation via the TransformationRule model, which defines regex patterns and replacement strings applied during the mapping process.
Sources: src/flext_target_ldap/models.py:168-185, src/flext_target_ldap/settings.py:129-135
Summary
The Service Runtime serves as the critical glue layer in flext-target-ldap. By providing adapter classes that implement the Singer protocol while delegating the complex LDAP interaction logic to specialized sinks, it maintains a clean separation of concerns. This architecture allows the target to benefit from standard Singer lifecycle management while enforcing strict LDAP schema and business rules through consolidated domain models.
Sources: src/flext_target_ldap/_utilities/service_runtime.py:13-15, src/flext_target_ldap/api.py:31-35