Skip to content

feat: add OptimizelyConfig API #274

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

Merged
merged 31 commits into from
Jan 10, 2020
Merged

feat: add OptimizelyConfig API #274

merged 31 commits into from
Jan 10, 2020

Conversation

jaeopt
Copy link
Contributor

@jaeopt jaeopt commented Nov 15, 2019

No description provided.

@jaeopt jaeopt requested a review from a team as a code owner November 15, 2019 18:28
@jaeopt jaeopt requested review from thomaszurkan-optimizely and removed request for a team November 15, 2019 19:02
@jaeopt jaeopt changed the base branch from jae/oc to 3.x.x December 2, 2019 23:32
@jaeopt jaeopt changed the base branch from 3.x.x to master January 7, 2020 21:55
Copy link
Contributor

@thomaszurkan-optimizely thomaszurkan-optimizely left a comment

Choose a reason for hiding this comment

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

I think there is an opportunity to do some really cool things here. why give access to maps that can go stale? why not instead support subscripting and make it as dynamic and realtime as possible? so instead of optimizely config as an object it is just a set of methods that access the project config (i.e. client.config.features["featureName"] as well as client.config.featureKeys[i]).
I think the main reason you would want it like this is to discourage holding onto potentially stale data.

@@ -16,12 +16,47 @@

import Foundation

struct FeatureFlag: Codable, Equatable {
struct FeatureFlag: Codable, Equatable, OptimizelyFeature {
static func == (lhs: FeatureFlag, rhs: FeatureFlag) -> Bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

why not have these as extensions?

@@ -16,7 +16,35 @@

import Foundation

struct Variable: Codable, Equatable {
struct Variable: Codable, Equatable, OptimizelyVariable {
Copy link
Contributor

Choose a reason for hiding this comment

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

i think this would be cleaner as an extension.

@@ -128,7 +128,7 @@ class DefaultDatafileHandler: OPTDatafileHandler {
completionHandler(result)

// avoid event-log-message preparation overheads with closure-logging
self.logger.d({ response.debugDescription })
//self.logger.d({ response.debugDescription })
Copy link
Contributor

Choose a reason for hiding this comment

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

should we remove this?

/// - Returns: a snapshot of public project configuration data model
/// - Throws: `OptimizelyError` if SDK is not ready
@available(swift, obsoleted: 1.0)
@objc(getOptimizelyConfigWithError:)
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this not a property?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess you're asking if we can use property for "optimizelyConfig" instead of get function. It's a possible option, but we can integrate error throw/return and also in this way, more consistent with other APIs.

@coveralls
Copy link

coveralls commented Jan 7, 2020

Coverage Status

Coverage decreased (-0.06%) to 98.899% when pulling d5bcf54 on jae/optConfigProtocol into 4b0d169 on master.

@jaeopt
Copy link
Contributor Author

jaeopt commented Jan 8, 2020

Tom, it's an interesting idea to let dynamically access updated data with subscripts. I thought about it but will put aside for now. It'll make sync issue complicated. We need to take a snapshot to provide data consistency. A consistency of API with other SDKs is also considered.

Copy link
Contributor

@thomaszurkan-optimizely thomaszurkan-optimizely left a comment

Choose a reason for hiding this comment

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

LGTM - a couple of nits. There is a commented out comment that should probably be removed. Also, it would be great if you could use one of the 27 datafiles we already have for testing instead of adding more. Thanks!

let task = session.uploadTask(with: request, from: event.body) { (_, response, error) in
self.logger.d(response.debugDescription)
let task = session.uploadTask(with: request, from: event.body) { (_, _, error) in
//self.logger.d(response.debugDescription)
Copy link
Contributor

Choose a reason for hiding this comment

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

remove?

@jaeopt jaeopt merged commit e2ef6a3 into master Jan 10, 2020
@jaeopt jaeopt deleted the jae/optConfigProtocol branch May 8, 2020 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants