-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: spawn reload and reset actions to all pods
- Loading branch information
Showing
5 changed files
with
117 additions
and
0 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
51 changes: 51 additions & 0 deletions
51
...main/java/org/geoserver/cloud/config/catalog/events/GeoServerLifecycleEventPublisher.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,51 @@ | ||
/* | ||
* (c) 2024 Open Source Geospatial Foundation - all rights reserved This code is licensed under the | ||
* GPL 2.0 license, available at the root application directory. | ||
*/ | ||
package org.geoserver.cloud.config.catalog.events; | ||
|
||
import lombok.NonNull; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import org.geoserver.cloud.event.lifecycle.LifecycleEvent; | ||
import org.geoserver.cloud.event.lifecycle.ReloadEvent; | ||
import org.geoserver.cloud.event.lifecycle.ResetEvent; | ||
import org.geoserver.config.impl.GeoServerLifecycleHandler; | ||
|
||
import java.util.function.Consumer; | ||
|
||
@RequiredArgsConstructor | ||
@Slf4j | ||
class GeoServerLifecycleEventPublisher implements GeoServerLifecycleHandler { | ||
|
||
private final @NonNull Consumer<? super LifecycleEvent> eventPublisher; | ||
|
||
void publish(@NonNull LifecycleEvent event) { | ||
eventPublisher.accept(event); | ||
} | ||
|
||
@Override | ||
public void onReset() { | ||
log.info("Publishing the onReset event"); | ||
|
||
publish(new ResetEvent()); | ||
} | ||
|
||
@Override | ||
public void onDispose() { | ||
log.info("Ignoring the onDispose event"); | ||
} | ||
|
||
@Override | ||
public void beforeReload() { | ||
log.info("Ignoring the beforeReload event"); | ||
} | ||
|
||
@Override | ||
public void onReload() { | ||
log.info("Publishing the onReload event"); | ||
|
||
publish(new ReloadEvent()); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/catalog/events/src/main/java/org/geoserver/cloud/event/lifecycle/LifecycleEvent.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,25 @@ | ||
/* | ||
* (c) 2024 Open Source Geospatial Foundation - all rights reserved This code is licensed under the | ||
* GPL 2.0 license, available at the root application directory. | ||
*/ | ||
package org.geoserver.cloud.event.lifecycle; | ||
|
||
import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
|
||
import org.geoserver.cloud.event.GeoServerEvent; | ||
|
||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT) | ||
@JsonSubTypes({ | ||
@JsonSubTypes.Type(value = ReloadEvent.class), | ||
@JsonSubTypes.Type(value = ResetEvent.class) | ||
}) | ||
public abstract class LifecycleEvent extends GeoServerEvent { | ||
|
||
@Override | ||
public String toShortString() { | ||
String originService = getOrigin(); | ||
String type = getClass().getSimpleName(); | ||
return "%s[origin: %s]".formatted(type, originService); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/catalog/events/src/main/java/org/geoserver/cloud/event/lifecycle/ReloadEvent.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,16 @@ | ||
/* | ||
* (c) 2024 Open Source Geospatial Foundation - all rights reserved This code is licensed under the | ||
* GPL 2.0 license, available at the root application directory. | ||
*/ | ||
package org.geoserver.cloud.event.lifecycle; | ||
|
||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
import com.fasterxml.jackson.annotation.JsonTypeName; | ||
|
||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT) | ||
@JsonTypeName("ReloadEvent") | ||
public class ReloadEvent extends LifecycleEvent { | ||
public ReloadEvent() { | ||
// no-op, for serialization | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/catalog/events/src/main/java/org/geoserver/cloud/event/lifecycle/ResetEvent.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,16 @@ | ||
/* | ||
* (c) 2024 Open Source Geospatial Foundation - all rights reserved This code is licensed under the | ||
* GPL 2.0 license, available at the root application directory. | ||
*/ | ||
package org.geoserver.cloud.event.lifecycle; | ||
|
||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
import com.fasterxml.jackson.annotation.JsonTypeName; | ||
|
||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT) | ||
@JsonTypeName("ResetEvent") | ||
public class ResetEvent extends LifecycleEvent { | ||
public ResetEvent() { | ||
// no-op, for serialization | ||
} | ||
} |