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

[1/2] Swift Concurrency migration - Financial Connections API client #4444

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mats-stripe
Copy link
Collaborator

@mats-stripe mats-stripe commented Jan 8, 2025

Summary

This PR introduces Swift Concurrency to the Financial Connections API client, laying the groundwork for a full migration. The changes are implemented in a way that allows for a gradual rollout without disrupting existing functionality. To do this seamlessly, we introduce two new classes;

  1. FinancialConnectionsAsyncAPIClient: A new API client fully powered by Swift Concurrency.
  2. FinancialConnectionsAPIClientFacade: A wrapper that encapsulates both the new async client and the existing Futures/Promises-based client.

Some implementation details:

  • The facade implements the FinancialConnectionsAPI protocol, maintaining the current interface for SDK consumers.
  • This approach allows us to isolate changes and continue using the existing API client in production while testing the new async implementation.

This work also provides a shape for the new async API. The current API is shaped as:

// Futures-based API
func synchronize(clientSecret: String, returnURL: String?) -> Future<FinancialConnectionsSynchronize>

While the new API is shaped as:

// Async-based API
func synchronize(clientSecret: String, returnURL: String?) async throws -> FinancialConnectionsSynchronize

A toggle has been added to the FC example app to switch between API client implementations. This is currently the only way to test the async API client:

image

Motivation

Move towards migration to Swift Concurrency

Next Steps: Part 2 will focus on migrating existing consumers to use the new async API client.

Testing

Unit tests added, and manual testing done.

Screen.Recording.2025-01-08.at.1.47.18.PM.mov

Changelog

N/a

Copy link

emerge-tools bot commented Jan 8, 2025

8 builds increased size

Name Version Download Change Install Change Approval
StripeSize
com.stripe.StripeSize
1.0 (1) 2.1 MB ⬇️ 152 B 7.0 MB ⬆️ 100 B N/A
StripePaymentsSize
com.stripe.StripePaymentsSize
1.0 (1) 1.2 MB ⬇️ 159 B (-0.01%) 4.2 MB ⬆️ 100 B N/A
StripePaymentsUISize
com.stripe.StripePaymentsUISize
1.0 (1) 1.9 MB ⬆️ 306 B (0.02%) 6.4 MB ⬆️ 100 B N/A
StripePaymentSheetSize
com.stripe.StripePaymentSheetSize
1.0 (1) 3.8 MB ⬆️ 527 B (0.01%) 11.1 MB ⬆️ 476 B N/A
StripeIdentitySize
com.stripe.StripeIdentitySize
1.0 (1) 1.4 MB ⬇️ 66 B 4.3 MB ⬆️ 100 B N/A
StripeApplePaySize
com.stripe.StripeApplePaySize
1.0 (1) 482.8 kB ⬆️ 158 B (0.03%) 1.7 MB ⬆️ 100 B N/A
⚠️ StripeFinancialConnectionsSize
com.stripe.StripeFinancialConnectionsSize
1.0 (1) 1.5 MB ⬆️ 67.0 kB (4.84%) 4.7 MB ⬆️ 197.0 kB (4.43%) N/A
⚠️ StripeConnectSize
com.stripe.StripeConnectSize
1.0 (1) 1.6 MB ⬆️ 67.5 kB (4.37%) 5.2 MB ⬆️ 193.6 kB (3.91%) N/A

StripeSize 1.0 (1)
com.stripe.StripeSize

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬆️ 100 B
Total download size change: ⬇️ 152 B

Largest size changes

Item Install Size Change
Other ⬆️ 100 B
View Treemap

Image of diff

StripePaymentsSize 1.0 (1)
com.stripe.StripePaymentsSize

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬆️ 100 B
Total download size change: ⬇️ 159 B (-0.01%)

Largest size changes

Item Install Size Change
Other ⬆️ 100 B
View Treemap

Image of diff

StripePaymentsUISize 1.0 (1)
com.stripe.StripePaymentsUISize

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬆️ 100 B
Total download size change: ⬆️ 306 B (0.02%)

Largest size changes

Item Install Size Change
Other ⬆️ 100 B
View Treemap

Image of diff

StripePaymentSheetSize 1.0 (1)
com.stripe.StripePaymentSheetSize

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬆️ 476 B
Total download size change: ⬆️ 527 B (0.01%)

Largest size changes

Item Install Size Change
Other ⬆️ 476 B
View Treemap

Image of diff

StripeIdentitySize 1.0 (1)
com.stripe.StripeIdentitySize

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬆️ 100 B
Total download size change: ⬇️ 66 B

Largest size changes

Item Install Size Change
Other ⬆️ 100 B
View Treemap

Image of diff

StripeApplePaySize 1.0 (1)
com.stripe.StripeApplePaySize

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬆️ 100 B
Total download size change: ⬆️ 158 B (0.03%)

Largest size changes

Item Install Size Change
Other ⬆️ 100 B
View Treemap

Image of diff

StripeFinancialConnectionsSize 1.0 (1)
com.stripe.StripeFinancialConnectionsSize

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬆️ 197.0 kB (4.43%)
Total download size change: ⬆️ 67.0 kB (4.84%)

Largest size changes

Item Install Size Change
Code Signature ⬆️ 4.7 kB
🗑 StripeFinancialConnections.NativeFlowAPIDataManager.manifest ⬇️ -2.0 kB
StripeFinancialConnections.NativeFlowAPIDataManager.init(manifest... ⬇️ -1.8 kB
StripeFinancialConnectionsSize ⬆️ 1.3 kB
StripeFinancialConnections.PartnerAuthViewController.handleAuthSe... ⬆️ 1.2 kB
View Treemap

Image of diff

StripeConnectSize 1.0 (1)
com.stripe.StripeConnectSize

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬆️ 193.6 kB (3.91%)
Total download size change: ⬆️ 67.5 kB (4.37%)

Largest size changes

Item Install Size Change
Code Signature ⬆️ 5.4 kB
🗑 StripeFinancialConnections.NativeFlowAPIDataManager.manifest ⬇️ -2.0 kB
StripeFinancialConnections.NativeFlowAPIDataManager.init(manifest... ⬇️ -1.8 kB
StripeConnectSize ⬆️ 1.3 kB
StripeFinancialConnections.PartnerAuthViewController.handleAuthSe... ⬆️ 1.2 kB
View Treemap

Image of diff


🛸 Powered by Emerge Tools

Comment trigger: Size diff threshold of 100.00kB exceeded

Copy link

github-actions bot commented Jan 8, 2025

🚨 New dead code detected in this PR:

FinancialConnectionsAsyncAPIClient.swift:144 warning: Protocol 'FinancialConnectionsAsyncAPI' is redundant as it's never used as an existential type
FinancialConnectionsAsyncAPIClient.swift:316 warning: Protocol 'FinancialConnectionsAsyncAPI' conformance is redundant

Please remove the dead code before merging.

If this is intentional, you can bypass this check by adding the label skip dead code check to this PR.

ℹ️ If this comment appears to be left in error, double check that the flagged code is actually used and/or make sure your branch is up-to-date with master.

@mats-stripe mats-stripe changed the title Mats/async fc api client Create new FC API client using Swift Concurrency Jan 8, 2025
@mats-stripe mats-stripe changed the title Create new FC API client using Swift Concurrency [1/2] Swift Concurrency migration - Financial Connections API client Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant