-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a666af
commit 94c237b
Showing
13 changed files
with
137 additions
and
41 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
40 changes: 40 additions & 0 deletions
40
...in/java/pl/allegro/tech/hermes/management/api/SubscriptionTerminationCleanupEndpoint.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,40 @@ | ||
package pl.allegro.tech.hermes.management.api; | ||
|
||
import jakarta.ws.rs.Consumes; | ||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.core.Response; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import pl.allegro.tech.hermes.api.Subscription; | ||
import pl.allegro.tech.hermes.api.SubscriptionName; | ||
import pl.allegro.tech.hermes.management.domain.subscription.SubscriptionService; | ||
import pl.allegro.tech.hermes.management.infrastructure.audit.AuditEvent; | ||
|
||
import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON; | ||
import static pl.allegro.tech.hermes.management.infrastructure.audit.AuditEventType.REMOVED; | ||
|
||
@Path("subscriptions/termination-cleanup") | ||
public class SubscriptionTerminationCleanupEndpoint { | ||
|
||
private final SubscriptionService subscriptionService; | ||
|
||
@Autowired | ||
public SubscriptionTerminationCleanupEndpoint(SubscriptionService subscriptionService) { | ||
this.subscriptionService = subscriptionService; | ||
} | ||
|
||
@POST | ||
@Consumes(APPLICATION_JSON) | ||
@Path("/from-audit-event") | ||
public Response subscriptionTerminationCleanup(AuditEvent auditEvent) { | ||
if (auditEvent.getEventType() != REMOVED | ||
|| !auditEvent.getPayloadClass().equals(Subscription.class.getName())) { | ||
return Response.ok().build(); | ||
} | ||
|
||
SubscriptionName subscriptionName = | ||
Subscription.getSubscriptionNameFromString(auditEvent.getResourceName()); | ||
subscriptionService.subscriptionTerminationCleanup(subscriptionName); | ||
return Response.ok().build(); | ||
} | ||
} |
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
3 changes: 2 additions & 1 deletion
3
...main/java/pl/allegro/tech/hermes/management/domain/subscription/ConsumerGroupManager.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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
package pl.allegro.tech.hermes.management.domain.subscription; | ||
|
||
import pl.allegro.tech.hermes.api.Subscription; | ||
import pl.allegro.tech.hermes.api.SubscriptionName; | ||
import pl.allegro.tech.hermes.api.Topic; | ||
|
||
public interface ConsumerGroupManager { | ||
|
||
void createConsumerGroup(Topic topic, Subscription subscription); | ||
|
||
void deleteConsumerGroup(Topic topic, Subscription subscription); | ||
void deleteConsumerGroup(SubscriptionName subscriptionName); | ||
} |
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
20 changes: 20 additions & 0 deletions
20
...l/allegro/tech/hermes/management/infrastructure/kafka/ConsumerGroupDeletionException.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,20 @@ | ||
package pl.allegro.tech.hermes.management.infrastructure.kafka; | ||
|
||
import pl.allegro.tech.hermes.api.ErrorCode; | ||
import pl.allegro.tech.hermes.api.SubscriptionName; | ||
import pl.allegro.tech.hermes.management.domain.ManagementException; | ||
|
||
import static java.lang.String.format; | ||
import static pl.allegro.tech.hermes.api.ErrorCode.CONSUMER_GROUP_DELETION_ERROR; | ||
|
||
public class ConsumerGroupDeletionException extends ManagementException { | ||
|
||
public ConsumerGroupDeletionException(SubscriptionName subscriptionName, Throwable e) { | ||
super(format("Failed to delete consumer group, for subscription %s ", subscriptionName), e); | ||
} | ||
|
||
@Override | ||
public ErrorCode getCode() { | ||
return CONSUMER_GROUP_DELETION_ERROR; | ||
} | ||
} |
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
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