Constants & Enums
Relevant source files
The following files were used as context for generating this wiki page:
The flext-tap-ldap project utilizes a centralized system for managing constants and enumerations, built upon the FLEXT unified pattern. This architecture ensures consistency across the LDAP tap extraction process by inheriting from core libraries (flext-core, flext-meltano, and flext-ldap) while defining project-specific values for LDAP connection handling, search configurations, and replication methods.
The primary namespace for these values is encapsulated in the FlextTapLdapConstants class, often aliased as c. This class facilitates cross-project access to LDAP-generic constants (like ports and timeouts) and Meltano-generic defaults (like batch sizes) through Method Resolution Order (MRO) mixin composition.
Sources: src/flext_tap_ldap/constants.py:16-30, src/flext_tap_ldap/models.py:25-35
Core Extraction Constants
The TapLdap namespace within the constants module defines the baseline operational parameters for the Singer tap. These include default sizes for paged results and timeout values derived from the parent FlextLdapConstants.
Search & Connection Defaults
| Constant | Type | Value | Description |
|---|---|---|---|
DEFAULT_PAGE_SIZE | int | 1000 | The default number of records to fetch per LDAP page. |
DEFAULT_SEARCH_TIMEOUT | int | 30 | Derived from FlextLdapConstants.Ldap.TIMEOUT. |
DEFAULT_HOST | str | localhost | Default LDAP server address. |
DEFAULT_SCOPE | str | "SUBTREE" | Default depth for LDAP search operations. |
MAX_PORT | int | 65535 | Maximum valid port number for LDAP connections. |
Sources: src/flext_tap_ldap/constants.py:34-69, tests/constants.py:30-45
Replication Methods
Replication strategy is managed via the Replication.Method enumeration. This uses a StrEnum to ensure type safety and provide a single source of truth for Singer replication behaviors, avoiding string duplication throughout the codebase.
The diagram shows the available replication methods used to determine how data is synchronized from the LDAP server to the Singer target.
Sources: src/flext_tap_ldap/constants.py:48-60
Client and Model Integration
Constants are deeply integrated into the models.py and client.py components to enforce validation and default behaviors. For example, the LdapConnectionParams model uses constants to set default page sizes and search timeouts.
Connection Parameter Mapping
The project uses specific constant values to initialize the LDAP client and validate connection strings.
The flow shows how configuration constants are applied during the initialization of the LDAP client and subsequent search operations.
Sources: src/flext_tap_ldap/client.py:126-146, src/flext_tap_ldap/models.py:65-100
Normalized Search Scopes
The ClientSupport utility provides normalization for scope strings to ensure they match valid LDAP constants.
BASE: Corresponds to a single entry search.ONELEVEL: Corresponds to entries immediately below the base DN.SUBTREE: Corresponds to all entries at all levels under the base DN.
Sources: src/flext_tap_ldap/_utilities/client_support.py:27-37
Test Infrastructure Constants
For testing environments, particularly those involving Docker, the project extends the production constants in tests/constants.py. The TestsFlextTapLdapConstants class mirrors the production structure but provides specific values for integration testing.
| Test Constant | Value | Description |
|---|---|---|
HOST | "test.ldap.com" | Mock LDAP server host. |
CONTAINER_PORT | 3390 | The internal port used by the test LDAP container. |
ADMIN_DN | "cn=admin,dc=flext,dc=local" | Default admin DN for test environments. |
USE_TLS | False | Default TLS setting for test suites. |
Sources: tests/constants.py:20-45
Conclusion
The use of FlextTapLdapConstants ensures that the tap remains compliant with the Singer protocol while adhering to the technical requirements of LDAP directory services. By leveraging inheritance from flext-ldap and flext-meltano, the project maintains a clean separation between generic LDAP logic and tap-specific extraction configurations.