Unleash / unleash-proxy-client-swift

Apache License 2.0
14 stars 20 forks source link

feat: configurable storage #63

Closed kwasniew closed 11 months ago

kwasniew commented 1 year ago

About the changes

You can inject your own poller that has custom implementation of the StorageProvider protocol. By default we provide in-memory implementation but any user of the SDK can use whatever local storage mechanism they want.

When constructing UnleashProxyClientSwift you need to inject Poller(refreshInterval: refreshInterval, unleashUrl: url, apiKey: clientKey, session: URLSession.shared, storageProvider: yourStorageProvideImpl)

Important files

Discussion points

qqKyleShin commented 11 months ago

Hi everyone. Since func createFeatureMap(features:) now stores the [Toggle] data in storageProvider instead of returning a result to be stored in Poller.toggles, I noticed func isEnabled(name:) in UnleashClientBase is still accessing data from Poller.toggles, causing the toggles accessed via isEnabled(name:) to always return false. https://github.com/Unleash/unleash-proxy-client-swift/blob/eed05048ad6518239a7098b46cc05dfcca6bce52/Sources/UnleashProxyClientSwift/UnleashProxyClientSwift.swift#L78

kwasniew commented 11 months ago

@qqKyleShin Thanks for bringing it to our attention. This is fixed now.

qqKyleShin commented 11 months ago

@kwasniew thank you!