Replies: 4 comments 13 replies
-
Thanks for creating a discussion about this and I appreciate you addressing your concerns and pain points. I’ll address your questions directly.
The reason for While this project works for Apple platforms, it’s also designed to work with Linux and Windows as well. This is especially true for Linux, as I want to ensure that a wide variety of hardware can run the project without using a lot of resources, from large servers to tiny devices like the Raspberry Pi. I feared having multiple instances of an I also want to be a good Swift package citizen and not decide on trying to use a ton of CPU and memory just because Apple devices have a ton of them. This is not fair to the developer, and it’s not fair to your users. Even though
To directly answer your question, technically, there isn’t a benefit here. For more context: I had the idea of sharing a single With that said, the way it’s implemented does cause an issue where each
This is something that I’ve thought about for a while, as We can discuss how this will be laid out with respect to what needs to happen, but from what I understand, the only think that should be done is to give each instance of |
Beta Was this translation helpful? Give feedback.
-
One point I forgot to ask here: why is the authentication header not added for custom RequestExecutors? |
Beta Was this translation helpful? Give feedback.
-
Since APIServiceClient is more or less stateless (when you initialize all properties in the init) it does not need to be an Here are my changes so far: commit APIServiceClient All the parameters of |
Beta Was this translation helpful? Give feedback.
-
One important point I want to highlight—yet is completely overlooked in the new approach—is the handling of URLSession. However, if a developer wants to use a shared URLSession, this is also possible by leveraging the ATRequestExecutor |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Goal
I'd like to use a custom implementation of
ATRequestExecutor
to track rate limits provided by the Bluesky API via the response headers.Problem
However, I've noticed that my custom
ATRequestExecutor
gets overwritten whenever a newATProtoKit
instance is created. For example, when usingSessionConfiguration.authenticate(with:password)
, theresponseProvider
argument is forwarded toAPIClientService.shared.configure(...)
, which means a single shared instance ofATRequestExecutor
is used across allATProtoKit
instances. Each time a new instance is created, the executor is replaced.Why This Is an Issue
In my use case, I need to maintain two separate
ATProtoKit
instances: one unauthenticated and one authenticated. My custom RequestExecutor needs access to the user's access token, which I can retrieve from theSessionConfiguration
’sKeychainProtocol
. However, since the executor is shared (and overwritten), I can't reliably associate different executors (and their configurations) with specificATProtoKit
instances.This issue occurs not just for my use case—there are other SDK methods and components, such as
ATFacetParser.parseFacets
and various view refresh methods, that internally create newATProtoKit
instances. These calls also overwrite the RequestExecutor in the sharedAPIClientService
.Questions
APIClientService
is implemented as a singleton shared instance?URLSession
(which, as implemented now, is also replaced on each newATProtoKit
instance)?ATProtoKit
instance instead?I really appreciate the design that allows custom
RequestExecutor
implementations, as this makes the networking layer easy to test and mock. However, the current shared instance approach seems to limit the intended modularity and flexibility.Thank you for your work on ATProtoKit, and I'm looking forward to any insights or suggestions you might have!
Beta Was this translation helpful? Give feedback.
All reactions