You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Move writeToCacheAsynchronously to the caller coroutine scope. This will remove a resource to manage.
Deprecate (and ultimately remove) ApolloClient.close(). Since we want to encourage sharing of the network resource
Rename NetworkTransport.dispose() to NetworkTransport.close()
Add ApolloClient.Builder.normalizedCache(ApolloStore) and promote it as the main entry point for the normalized cache. By having the caller create the ApolloStore, it makes it more obvious that it needs to be closed.
Decide what to do with HttpInterceptor.close()
Update all tests to release all their resources always.
At the end of the day, I think a good target to close resources is:
NetworkTransport and ApolloStore would take ownership of their resources (contrary to ApolloClient). This is because they are interfaces. A NetworkTransport could possibly be closed with networkTransport.okHttpClient.connectionPool.evictAll() but another would need something else so we need the NetworkTransport.close().
Doing the above invalidate other clients sharing the NetworkTransport/ApolloStore (for an example, created through newBuilder). We might want to add special wording to newBuilder() to guard against sharing an ApolloStore (which, although shareable is potentially dangerous)
The text was updated successfully, but these errors were encountered:
Description
This is a tracking issue for improving resource management in Apollo Kotlin. There's a tradeoff between:
"Soft" resources (will be eventually released but close() is required for prompt release):
BatchingHttpInterceptor.scope
WebSocketNetworkTransport.coroutineScope
(ws)WebSocketPool
(websocket)OkHttpClient.dispatcher.executorService
OkHttpClient.conectionPool
writeToCacheAsynchronously
"Hard" resources (require a call to close() or will leak forever or display a warning)
AndroidSqliteDriver.close()
NSUrlSession
Issues with closing resources:
Note: OkHttp uses daemon threads since
4.5.0+
and hanging apps shouldn't be an issue anymoreTODO:
writeToCacheAsynchronously
to the caller coroutine scope. This will remove a resource to manage.ApolloClient.close()
. Since we want to encourage sharing of the network resourceNetworkTransport.dispose()
toNetworkTransport.close()
ApolloClient.Builder.normalizedCache(ApolloStore)
and promote it as the main entry point for the normalized cache. By having the caller create theApolloStore
, it makes it more obvious that it needs to be closed.HttpInterceptor.close()
At the end of the day, I think a good target to close resources is:
NetworkTransport
andApolloStore
would take ownership of their resources (contrary toApolloClient
). This is because they are interfaces. ANetworkTransport
could possibly be closed withnetworkTransport.okHttpClient.connectionPool.evictAll()
but another would need something else so we need theNetworkTransport.close()
.Doing the above invalidate other clients sharing the
NetworkTransport
/ApolloStore
(for an example, created throughnewBuilder
). We might want to add special wording tonewBuilder()
to guard against sharing anApolloStore
(which, although shareable is potentially dangerous)The text was updated successfully, but these errors were encountered: