This repository has been archived by the owner on Jul 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #171 from indeedeng/EXP-660-Payload-Experiment-MVP
EXP-660: Payload Experiment MVP
- Loading branch information
Showing
17 changed files
with
883 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
proctor-common/src/main/java/com/indeed/proctor/common/PayloadProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.indeed.proctor.common; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.extern.jackson.Jacksonized; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Jacksonized | ||
public class PayloadProperty { | ||
private String testName; | ||
private JsonNode value; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
proctor-common/src/main/java/com/indeed/proctor/common/dynamic/NamespacesFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.indeed.proctor.common.dynamic; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonTypeName; | ||
import com.google.common.base.Preconditions; | ||
import com.google.common.collect.ImmutableSet; | ||
import com.indeed.proctor.common.model.ConsumableTestDefinition; | ||
import com.indeed.proctor.common.model.PayloadExperimentConfig; | ||
import org.springframework.util.CollectionUtils; | ||
|
||
import java.util.Collections; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
@JsonTypeName("namespaces_filter") | ||
public class NamespacesFilter implements DynamicFilter { | ||
private final Set<String> namespaces; | ||
|
||
public NamespacesFilter(@JsonProperty("namespaces") final Set<String> namespaces) { | ||
Preconditions.checkArgument( | ||
!CollectionUtils.isEmpty(namespaces), | ||
"namespaces should be non-empty string list."); | ||
this.namespaces = ImmutableSet.copyOf(namespaces); | ||
} | ||
|
||
@JsonProperty("namespaces") | ||
public Set<String> getNamespaces() { | ||
return this.namespaces; | ||
} | ||
|
||
@Override | ||
public boolean matches(final String testName, final ConsumableTestDefinition testDefinition) { | ||
final boolean isMatched = | ||
Optional.ofNullable(testDefinition.getPayloadExperimentConfig()) | ||
.map(PayloadExperimentConfig::getNamespaces).orElse(Collections.emptyList()) | ||
.stream() | ||
.anyMatch(this.namespaces::contains); | ||
testDefinition.setDynamic(isMatched); | ||
return isMatched; | ||
} | ||
|
||
@Override | ||
public boolean equals(final Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
final NamespacesFilter that = (NamespacesFilter) o; | ||
return namespaces.equals(that.namespaces); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(namespaces); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.