feat: Added ODPManager implementation#489
Conversation
jaeopt
left a comment
There was a problem hiding this comment.
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.
Customization of segmentCache size/timeout and segmentCache itself as well?
There was a problem hiding this comment.
We also need to support for "disable" entire ODP functions.
There was a problem hiding this comment.
There are two constructors.
- First one only takes the two mandatory arguments of
ODPConfigandApiManagerand 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
SegmentManagerwith 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.
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.
There are two constructors.
- First one only takes the two mandatory arguments of
ODPConfigandApiManagerand 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
SegmentManagerwith 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
SDKinstance 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.
I am thinking of handling disable / enable at
optimizelylevel. 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.
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.
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.
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.
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.
See TDD which defines accepted types for event data.
There was a problem hiding this comment.
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.
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.
jaeopt
left a comment
There was a problem hiding this comment.
Looks good. A couple of small changes suggested.
|
|
||
| @Transient | ||
| public Boolean isDataValid() { | ||
| for (Object entry: this.data.values()) { |
|
|
||
| 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.
Can we change it to standard message - "ODP event send failed ()"
2. Fixed ODP event error message
Summary
Added ODPManager Implementation which does the following.
Test plan
Issues
FSSDK-8388