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

Sample app provisioning #343

Merged
merged 13 commits into from
Mar 14, 2022
Merged

Sample app provisioning #343

merged 13 commits into from
Mar 14, 2022

Conversation

ikurek
Copy link
Contributor

@ikurek ikurek commented Mar 4, 2022

This should resolve #316, as this PR is a rework of Ably SDK key provisioning system. Previously, only the integration testing was using provisioning endpoints, an now they're also utilized in the sample application, to make it work without the SDK key. The most important changes are:

  • Provisioning was moved from test_integration to ably_flutter base package. This makes provisioning system available to all sub-packages of ably_flutter including test_integration and example.
  • Static provision() and getTokenRequest() methods were moved to a AppProvisioning class, which instance can be configured with additional parameters to extend provisioning capabilities
  • Example application initialization was changed to request API key before the app is started. Sadly, this can't be done in a different way, because AblyService in the example app has to be initialized before the app UI is ran
  • A small ApiKeyService utility class was created to manage API key, so it's possible to check the key source at runtime
  • Sample app UI was updated to show a warning message if currently used key comes from automatic provisioning system.

After that, we only need #318 to make the sample app run without any configuration from user's side 🙂

@ikurek ikurek self-assigned this Mar 4, 2022
@github-actions github-actions bot temporarily deployed to staging/pull/343/dartdoc March 4, 2022 15:59 Inactive
Copy link
Contributor

@QuintinWillison QuintinWillison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, why is app_provisioning.dart appearing in the main SDK sources? It's not in the client library features specification, as far as I'm aware, so shouldn't be part of the SDK unless we have strong reasons why it's required for the Flutter platform. If it's a utility that you need to share between example/ and test_integration/ projects, then is there a way to share it without adding to the API surface area of the core SDK?

README.md Outdated Show resolved Hide resolved
pubspec.yaml Outdated Show resolved Hide resolved
@ikurek
Copy link
Contributor Author

ikurek commented Mar 7, 2022

Actually, why is app_provisioning.dart appearing in the main SDK sources? It's not in the client library features specification, as far as I'm aware, so shouldn't be part of the SDK unless we have strong reasons why it's required for the Flutter platform. If it's a utility that you need to share between example/ and test_integration/ projects, then is there a way to share it without adding to the API surface area of the core SDK?

I don't think it's possible to share it between test_integration and example - these two are on the same level in the dependency tree, and they both are dependent on ably_flutter. With the approach I proposed in this PR:

  1. Both sub-packages can use a single provisioning system
  2. Users can use the provisioning methods easily for their own needs

But as you noticed, the main drawback is the fact that this class has to be in the base package. If we'd like to keep the codebase of the library as clean as possible, there are alternative approaches that I can take with this:

  1. Move the provisioning system to a separate repository - probably too much work, but we can make the provisioning system a completely separate module, with a separate codebase and repository. Then we can use that repository as a dependency in both subpackages of this repository
  2. Duplicate the provisioning class in both subpackages - it's fairly easy to do, but we'll have to remember to introduce changes to both of them in the future

If extending the base package like I've done it is not a correct direction, I suggest we take the approach 2, and simply put a copy of the class I created for provisioning in example and test_integration 🙂

@QuintinWillison
Copy link
Contributor

@ikurek Thanks for your detailed reply. It's worth us avoiding adding APIs to the base package because we've seen elsewhere that customer's can come to rely upon such unofficial (public, not public) APIs - and, in turn, we then have to support them going forwards. In the same vein, while your alternative approach 1 is a good suggestion, it only takes us further down the road of this becoming a supported public API.

So, on balance, I think go with your alternative approach 2 - duplicated code - and just ensure to put a comment in both locations that points to the other to help maintainers out. Perhaps also explaining why.

@ikurek
Copy link
Contributor Author

ikurek commented Mar 8, 2022

@QuintinWillison I've removed provisioning from base ably_flutter and moved it to both example and test_integration separately in 9dc9664

@ikurek ikurek requested a review from QuintinWillison March 8, 2022 16:45
@github-actions github-actions bot temporarily deployed to staging/pull/343/dartdoc March 8, 2022 16:47 Inactive
Copy link
Contributor

@ikbalkaya ikbalkaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me except a small typo which Quintin already suggested a change. So I'm going to assume it's going to be fixed

README.md Outdated Show resolved Hide resolved
@github-actions github-actions bot temporarily deployed to staging/pull/343/dartdoc March 10, 2022 15:37 Inactive
@ably ably deleted a comment Mar 10, 2022
@ably ably deleted a comment Mar 10, 2022
@ikurek ikurek deleted the feature/example-app-provisioning branch March 14, 2022 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Example App should be able to build and run without ABLY_API_KEY
3 participants