-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add KafkaPullFarm. Switch to Push and Pull approach
- Loading branch information
skarpenko
committed
Jan 29, 2024
1 parent
ad9981d
commit 4e0e641
Showing
18 changed files
with
626 additions
and
117 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
10 changes: 0 additions & 10 deletions
10
common/src/main/java/com/playtika/shepherd/common/Pasture.java
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
common/src/main/java/com/playtika/shepherd/common/Shepherd.java
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
common/src/main/java/com/playtika/shepherd/common/pull/Farm.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,31 @@ | ||
package com.playtika.shepherd.common.pull; | ||
|
||
import com.playtika.shepherd.common.PastureListener; | ||
|
||
import java.nio.ByteBuffer; | ||
|
||
/** | ||
* Farm has many herds distributed evenly by pastures | ||
*/ | ||
public interface Farm { | ||
|
||
/** | ||
* Here we come to Farm with our Pasture to graze specific Herd on it. | ||
* | ||
* @param herd Herd we want to inhabit this pasture | ||
* @param pastureListener Will listen for animals from Herd that will be assigned to our Pasture | ||
* @return Shepherd allows to set Herd population | ||
*/ | ||
Pasture addPasture(Herd<ByteBuffer> herd, PastureListener<ByteBuffer> pastureListener); | ||
|
||
/** | ||
* Here we come to Farm with our Pasture to graze specific Breeding Herd on it. | ||
* | ||
* @param herd Herd we want to inhabit this pasture | ||
* @param breedClass Only elements of this class accepted in this herd | ||
* @param pastureListener Will listen for animals from Herd that will be assigned to our Pasture | ||
* @return Shepherd allows to set Herd population | ||
*/ | ||
<Breed> Pasture addBreedingPasture(Herd<Breed> herd, Class<Breed> breedClass, PastureListener<Breed> pastureListener); | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
common/src/main/java/com/playtika/shepherd/common/pull/Herd.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,17 @@ | ||
package com.playtika.shepherd.common.pull; | ||
|
||
/** | ||
* Provides population | ||
* @param <Breed> | ||
*/ | ||
public interface Herd<Breed> { | ||
|
||
String getName(); | ||
|
||
Population<Breed> getPopulation(); | ||
|
||
void reset(); | ||
|
||
record Population<Breed>(Breed[] population, int version) { | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
common/src/main/java/com/playtika/shepherd/common/pull/Pasture.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,12 @@ | ||
package com.playtika.shepherd.common.pull; | ||
|
||
import java.time.Duration; | ||
|
||
public interface Pasture { | ||
|
||
Shepherd getShepherd(); | ||
|
||
void start(); | ||
|
||
void close(Duration timeout); | ||
} |
10 changes: 10 additions & 0 deletions
10
common/src/main/java/com/playtika/shepherd/common/pull/Shepherd.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,10 @@ | ||
package com.playtika.shepherd.common.pull; | ||
|
||
/** | ||
* Allows to rebalance population among pastures | ||
*/ | ||
public interface Shepherd { | ||
|
||
void rebalanceHerd(); | ||
|
||
} |
4 changes: 3 additions & 1 deletion
4
...va/com/playtika/shepherd/common/Farm.java → ...m/playtika/shepherd/common/push/Farm.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
15 changes: 15 additions & 0 deletions
15
common/src/main/java/com/playtika/shepherd/common/push/Pasture.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,15 @@ | ||
package com.playtika.shepherd.common.push; | ||
|
||
import java.time.Duration; | ||
|
||
public interface Pasture<Breed> { | ||
|
||
Shepherd<Breed> getShepherd(); | ||
|
||
/** | ||
* Set population via Shepherd before calling this method | ||
*/ | ||
void start(); | ||
|
||
void close(Duration timeout); | ||
} |
18 changes: 18 additions & 0 deletions
18
common/src/main/java/com/playtika/shepherd/common/push/Shepherd.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.playtika.shepherd.common.push; | ||
|
||
/** | ||
* Allows to set herd population | ||
* @param <Breed> | ||
*/ | ||
public interface Shepherd<Breed> { | ||
|
||
/** | ||
* | ||
* @param population | ||
* @param version | ||
* @return true if it will cause rebalance, false if population will be ignored | ||
*/ | ||
|
||
boolean setPopulation(Breed[] population, int version); | ||
|
||
} |
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.