You can create your own provider, which will be used by the DefaultCxUpdateSegmentStrategy.
Context
The DefaultCxUpdateSegmentStrategy interface assumes that providers can obtain segments at any moment. However, since the process of retrieving segments from external sources may be both time- and transfer-consuming, you should minimize the number of calls.
Procedure
Create an implementation of the UserSegmentsProvider interface.
public class SampleSegmentsProvider implements SegmentsProvider
{
private static final String PROVIDER_ID = "SAMPLEID";
@Override
public Optional<List<BaseSegmentData>> getSegments()
{
//get segments data from external system
final List<BaseSegmentData> segments = ...
...
//return segment list
return Optional.of(segments);
}
@Override
public String getProviderId()
{
return PROVIDER_ID;
}
}
The getSegments method of the interface should return:
a list of segments from given providers,
an Optional.empty if there is no segment
null if the segment provider can't provide new data, and doesn't want the existing data to be changed.
The getProviderId method of the interface should return provider identifier. There is a default implementation of this method, which returns the DEFAULT identifier. This method should be implemented when:
you want be able to set separate configuration for your provider,
you want to have specific prefix for segments returned by provider.