Skip to content

Traffic Allocations for Twilio - #18

Merged
adilaijaz merged 8 commits into
masterfrom
twilio2
Mar 28, 2017
Merged

adilaijaz merged 8 commits into
masterfrom
twilio2

Conversation

@adilaijaz

Copy link
Copy Markdown
Contributor
  • Support for Traffic Allocations
  • Introduced an ImpressionListener so we do not have to expose the label in the getTreatment.
  • We no longer have the ability to set refresh rates to less than 30 seconds.
if (_featuresRefreshRate <= 0) {
throw new IllegalArgumentException("featuresRefreshRate must be > 0: " + _featuresRefreshRate);
if (_featuresRefreshRate < 30 ) {
throw new IllegalArgumentException("featuresRefreshRate must be >= 30: " + _featuresRefreshRate);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we not error out and set our default + logging WARN?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

tell me what you want and I can do that


if (bucket >= parsedSplit.trafficAllocation()) {
// out of split
return new TreatmentLabelAndChangeNumber(parsedSplit.defaultTreatment(), "not in split", parsedSplit.changeNumber());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can this "not in split" be a constant in a LABELs class or enum like other SDKs?
Same for "killed", "exception" etc.

final ImpressionListener impressionListener;

if (config.impressionListener() != null) {
AsynchronousImpressionListener wrapper = AsynchronousImpressionListener.build(config.impressionListener(), config.impressionListenerCapactity());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

in this branch of the if statement (when both listeners exist), which one executes first?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

when both listeners exist, then we create a federated listener of our listener (that uploads impressions to our endpoint) and theirs

private final Long _changeNumber;


public Impression(String key, String bucketingKey, String split, String treatment, long time, String appliedRule, Long changeNumber) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't we already have KeyImpression?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we do, but that is an internal API. This is an API meant for external consumption. Reasons for keeping them separate:

  • We may be in a world down the road where we are sending more data to ourselves than to an external API
  • The internal api says 'label' and 'feature'. For external API, i am using 'appliedRule' and 'spilt' to be more consistent with the UI.

@Test
public void getBucket() {
System.out.println(Splitter.getBucket("pato@split.io", 123));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we improve this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment thread pom.xml Outdated
<module>client</module>
</modules>
<build>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what changed here? more dependencies?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

just the version number

_debugEnabled = debugEnabled;
_labelsEnabled = labelsEnabled;
_impressionListener = impressionListener;
_impressionListenerCapacity = impressionListenerCapacity;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what's the default?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There is no default. The method in the builder is:

public Builder impressionListener(ImpressionListener impressionListener, int capacity) {
// code
}

which means that when you provide the impression listener, you also provide the capacity

.setNameFormat("impression-listener-wrapper-%d")
.build();

ExecutorService executor = new ThreadPoolExecutor(2, 2, 0L, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(capacity), threadFactory);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the rejection policy used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

AbortPolicy. The wrapper catches any RejectedExecutions.

@adilaijaz
adilaijaz merged commit 3e94a10 into master Mar 28, 2017
bot2-harness pushed a commit that referenced this pull request Oct 8, 2026
@sonarqube-pull-requests

Copy link
Copy Markdown

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants