Skip to content

Conversation

@mikeproeng37
Copy link
Contributor

@mikeproeng37 mikeproeng37 commented Nov 20, 2019

Summary

  • Add a top-level wrapper to simplify how users interface with the SDK.
  • Removes the CMD package as we'll be moving that to Sidedoor because having a root exportable package is not compatible with it.

Copy link
Contributor

@pawels-optimizely pawels-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 understand the concept, (currently, 2 main.go files don't run with these changes)

Copy link
Contributor

@mikecdavis mikecdavis 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 this is a good start. I like having a clear entry point into the SDK. What are your thoughts on moving the entire contents of the client package into the root? So it's not a "wrapper" it just "is".

main.go Outdated
***************************************************************************/

package main
package optimizely
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like we can't mix the "application" (e.g. "package main") with an importable package. Perhaps we just remove this CLI and move it into the sidedoor repo instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I think that would make it simpler.

examples/main.go Outdated

"github.com/optimizely/go-sdk"
"github.com/optimizely/go-sdk/pkg/client"
"github.com/optimizely/go-sdk/pkg/entities"
Copy link
Contributor

Choose a reason for hiding this comment

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

This import is no longer used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is tricky because when imported, we import the namespace "optimizely", which is the package name and we would be referring to this import via optimizely.xxx

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 @mikecdavis is talking about "github.com/optimizely/go-sdk/pkg/entities", this is unused.

/************* StaticClient ********************/

optimizelyClient, err := optimizelyFactory.StaticClient()
optimizelyClient, err = optimizelyFactory.StaticClient()
Copy link
Contributor

Choose a reason for hiding this comment

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

err is no longer defined.

@mikeproeng37
Copy link
Contributor Author

mikeproeng37 commented Nov 22, 2019

I think this is a good start. I like having a clear entry point into the SDK. What are your thoughts on moving the entire contents of the client package into the root? So it's not a "wrapper" it just "is".

Yeah I thought about doing that, but I didn't want to introduce that big of a breaking change, even though we are technically still beta. I'd like to reserve that for a v2 so we can avoid breaking existing usage as well as documentation.

Something else I am considering though is whether we want to introduce singleton usage in v1 or we reserve that for v2. It will depend on feedback we get from customers. But I can see this being a broader SDK-wide feature that we enable across most other SDKs.

@mjc1283
Copy link
Contributor

mjc1283 commented Nov 22, 2019

I think this makes sense as a first step. Agree with @mikeng13 's comments about breaking changes, v2, customer feedback, and singleton/instance container.

@mikeproeng37 mikeproeng37 marked this pull request as ready for review November 25, 2019 19:08
@mikeproeng37 mikeproeng37 requested a review from a team as a code owner November 25, 2019 19:08
Copy link
Contributor

@pawels-optimizely pawels-optimizely 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, we can also remove cobra package from go.mod if we don't need that anymore.


Each supported SDK API method is it's own [cobra](https://github.com/spf13/cobra) command and requires the
input of an `--sdkKey`.
## Installation
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be easier to review by looking at the full file

examples/main.go Outdated

"github.com/optimizely/go-sdk"
"github.com/optimizely/go-sdk/pkg/client"
"github.com/optimizely/go-sdk/pkg/entities"
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 @mikecdavis is talking about "github.com/optimizely/go-sdk/pkg/entities", this is unused.

}
)
optimizelyClient, err := optimizely.Client(sdkKey)
enabled, _ := optimizelyClient.IsFeatureEnabled("mutext_feat", user)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm getting an error below because we define enabled here.

@mikeproeng37 mikeproeng37 merged commit ab7cfc3 into master Nov 26, 2019
@mikeproeng37 mikeproeng37 deleted the mng/package-wrapper branch November 26, 2019 18:33
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.

5 participants