feat(framework): Added Connector Environment support as environment config #430
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Connector Environment Architecture Explanation
Let me explain the complete architecture around
connector.environmentin this codebase.1. Configuration Layer (TOML Files)
In
config/development.toml,config/sandbox.toml, andconfig/production.toml, there's a structure:[connectors] environment: This is the master switch that determines which environment (sandbox or production) is currently active[connectors.sandbox]: Contains all connector configurations for sandbox/testing environments[connectors.production]: Contains all connector configurations for production/live environmentsWhen the application starts, the appropriate TOML file is loaded based on the runtime environment, and the
environmentfield tells the system which config set to use.2. Type Definitions (types.rs)
Enum Definition
This enum maps directly to the string values in the TOML (
"sandbox"→Sandbox,"production"→Production) via serde deserialization.Connector Struct
The
Connectorsstruct:environment)sandboxandproduction)Config Set
Each connector has its params (URLs, etc.) stored in the appropriate config set.
3. The
get_config()ImplementationThis is a simple but elegant pattern:
&self(a reference to the currentConnectorsinstance)ConnectorConfigSet4. Usage Pattern in Connector Files
In individual connector files (like
stripe.rs,adyen.rs, etc.), you'll typically see:5. Complete Data Flow
6. Key Benefits of This Architecture
get_config()- prevents accidental wrong environment useSummary
The
connector.environmentis essentially a routing mechanism that directs the application to the correct set of connector endpoints. Theget_config()method is the "dispatcher" that, based on the environment flag, hands you the right configuration set without any runtime overhead beyond a simple enum match.Would you like me to show you a specific connector file to see how it's used in practice?
Motivation and Context
Additional Changes
How did you test it?