-
Notifications
You must be signed in to change notification settings - Fork 32
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
feat: Added ODPManager implementation #489
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Some changes and clarifications suggested.
this(odpConfig, new ODPSegmentManager(odpConfig, apiManager), new ODPEventManager(odpConfig, apiManager)); | ||
} | ||
|
||
public ODPManager(@Nonnull ODPConfig odpConfig, @Nonnull ODPSegmentManager segmentManager, @Nonnull ODPEventManager eventManager) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Customization of segmentCache size/timeout and segmentCache itself as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to support for "disable" entire ODP functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two constructors.
- First one only takes the two mandatory arguments of
ODPConfig
andApiManager
and initializes everything else on default values. - If you want to customize anything at all, use the second constructor which expects you to pass everything from the outside. This is where you will have a chance to initialize your own
SegmentManager
with your owncacheOptions
.
I will recommend to keep these two options for now. We can provide other combinations at the level of factory methods to create the SDK
instance later as needed. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am thinking of handling disable / enable at optimizely
level. When enabled, ODP object will be there and it will always work. When disabled, there will be no ODP instance at all. What do you suggest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two constructors.
- First one only takes the two mandatory arguments of
ODPConfig
andApiManager
and initializes everything else on default values.- If you want to customize anything at all, use the second constructor which expects you to pass everything from the outside. This is where you will have a chance to initialize your own
SegmentManager
with your owncacheOptions
.I will recommend to keep these two options for now. We can provide other combinations at the level of factory methods to create the
SDK
instance later as needed. What do you think?
I see adjusting cache size and timeout more likely options for clients rather than full Cache and OdpManager customazations. Providing that path with factory will be also a good solution too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am thinking of handling disable / enable at
optimizely
level. When enabled, ODP object will be there and it will always work. When disabled, there will be no ODP instance at all. What do you suggest?
I was concerned about "if odpManager == null" checking in many places we need odpManager. We can try wrap those checking in OdpManager. Other than that, disabling at the top level is also a good option too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would advise to defer this discussion till the top level PR. We can then see if it looks good at top level other wise i will add this to ODPManager. what do you say?
public void close() { | ||
eventManager.stop(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not have top-level fetchSegments
and sendEvent
apis. Is it a plan to open directly from OdpEventManager
and OdpSegmentManager
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is expected to filter out api requests in this level (like "disable" discards all requests). Also sendEvent data type should be validated here (are we doing this in OdpEventManager?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disable: I am expecting disable to be handled in optimizely
object which will never go to ODPManager at all if disabled.
SendEvent Data validation: I am not sure what validation needs to be done. But if there is one, i would like to add that to eventManager
itself. What do you suggest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See TDD which defines accepted types for event data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
about top level fetch and event methods, SegmentManager
and EventManager
provide some overrides. If i add all those overrides, it looks redundant. I thought it made more sense to provide access to segmentManager and eventManager directly through getters to use those methods.
} | ||
|
||
public Boolean updateSettings(String apiHost, String apiKey, List<String> allSegments) { | ||
ODPConfig newConfig = new ODPConfig(apiKey, apiHost, allSegments); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we flush events in queue before updating apiKey/apiHost? It should not be common but when clients change the ODP account, all events in the queue should be flushed to the old account.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. A couple of small changes suggested.
|
||
@Transient | ||
public Boolean isDataValid() { | ||
for (Object entry: this.data.values()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null is also valid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -85,6 +87,10 @@ public void identifyUser(@Nullable String vuid, String userId) { | |||
} | |||
|
|||
public void sendEvent(ODPEvent event) { | |||
if (!event.isDataValid()) { | |||
logger.error("Error Sending Event: ODP data is not valid"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change it to standard message - "ODP event send failed ()"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
2. Fixed ODP event error message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary
Added ODPManager Implementation which does the following.
Test plan
Issues
FSSDK-8388