-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event processor reset with admin api #193
Open
trimoq
wants to merge
5
commits into
main
Choose a base branch
from
feature/event-processor-reset-with-admin-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b53256b
added more tests and reworked rest
trimoq 9280991
Reset event processor using Admin API - Work in progress.
saratry 2d54d51
Simplified examples and added tests
trimoq c6140dd
Adjusted variable names and added comments to make sample code easier…
trimoq b51f8a9
Using upstream axon server 4.6
trimoq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
23 changes: 23 additions & 0 deletions
23
reset-handler/src/main/java/io/axoniq/config/ConfigBasedAdminChannel.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,23 @@ | ||
package io.axoniq.config; | ||
|
||
import io.axoniq.axonserver.connector.admin.AdminChannel; | ||
import org.axonframework.axonserver.connector.AxonServerConnectionManager; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.stereotype.Component; | ||
|
||
|
||
/* | ||
Creates an admin channel from the configuration. used to simplify testing in other components. | ||
*/ | ||
@Component | ||
public class ConfigBasedAdminChannel { | ||
public ConfigBasedAdminChannel(AxonServerConnectionManager axonServerConnectionManager){ | ||
this.axonServerConnectionManager = axonServerConnectionManager; | ||
} | ||
private final AxonServerConnectionManager axonServerConnectionManager; | ||
|
||
@Bean | ||
public AdminChannel adminChannel() { | ||
return axonServerConnectionManager.getConnection().adminChannel(); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
reset-handler/src/main/java/io/axoniq/config/StringToEventProcessorServiceConverter.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,41 @@ | ||
package io.axoniq.config; | ||
|
||
import io.axoniq.service.FrameworkEventProcessorService; | ||
import io.axoniq.service.ServerConnectorEventProcessorService; | ||
import io.axoniq.service.EventProcessorService; | ||
import io.axoniq.service.RestEventProcessorService; | ||
import org.springframework.core.convert.converter.Converter; | ||
import org.springframework.stereotype.Component; | ||
|
||
/* | ||
Extract the service using the specified method to reset the token. | ||
This allows for cleaner signatures in the controllers and the services | ||
*/ | ||
@Component | ||
public class StringToEventProcessorServiceConverter implements Converter<String, EventProcessorService> { | ||
|
||
final RestEventProcessorService restEventProcessorService; | ||
final FrameworkEventProcessorService frameworkEventProcessorService; | ||
final ServerConnectorEventProcessorService serverConnectorEventProcessorService; | ||
|
||
public StringToEventProcessorServiceConverter(RestEventProcessorService restEventProcessorService, FrameworkEventProcessorService frameworkEventProcessorService, ServerConnectorEventProcessorService serverConnectorEventProcessorService) { | ||
this.restEventProcessorService = restEventProcessorService; | ||
this.frameworkEventProcessorService = frameworkEventProcessorService; | ||
this.serverConnectorEventProcessorService = serverConnectorEventProcessorService; | ||
} | ||
|
||
/* | ||
Match the passed string against a set of known constants. | ||
This is not elegant but does get its job done for the sample. | ||
*/ | ||
@Override | ||
public EventProcessorService convert(String from) { | ||
switch (from){ | ||
case "server": return serverConnectorEventProcessorService; | ||
case "rest": return restEventProcessorService; | ||
case "grpc": throw new IllegalArgumentException(); | ||
case "framework": return frameworkEventProcessorService; | ||
default: throw new IllegalArgumentException(); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
reset-handler/src/main/java/io/axoniq/config/WebConfig.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,24 @@ | ||
package io.axoniq.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.format.FormatterRegistry; | ||
import org.springframework.web.reactive.config.WebFluxConfigurer; | ||
|
||
/** | ||
* Add a Converter from String to EventProcessorService. | ||
* We can for example map `framework` to a FrameworkEventProcessorService | ||
*/ | ||
@Configuration | ||
public class WebConfig implements WebFluxConfigurer { | ||
|
||
final StringToEventProcessorServiceConverter converter; | ||
|
||
public WebConfig(StringToEventProcessorServiceConverter converter) { | ||
this.converter = converter; | ||
} | ||
|
||
@Override | ||
public void addFormatters(FormatterRegistry registry) { | ||
registry.addConverter(converter); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
reset-handler/src/main/java/io/axoniq/controller/EventProcessorRestController.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,35 @@ | ||
package io.axoniq.controller; | ||
|
||
import io.axoniq.service.EventProcessorService; | ||
import org.axonframework.config.Configuration; | ||
import org.springframework.util.Assert; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import reactor.core.publisher.Mono; | ||
|
||
/** | ||
* Uses the EventProcessorService provided to it based on the supplied method | ||
*/ | ||
@RestController | ||
public class EventProcessorRestController { | ||
|
||
@GetMapping("{method}/start/{processorName}") | ||
public Mono<Void> start(@PathVariable("method") EventProcessorService service, @PathVariable String processorName) { | ||
Assert.hasText(processorName, "Processing Group is mandatory and can't be empty!"); | ||
return service.start(processorName); | ||
} | ||
|
||
@GetMapping("{method}/pause/{processorName}") | ||
public Mono<Void> pause(@PathVariable("method") EventProcessorService service, @PathVariable String processorName) { | ||
Assert.hasText(processorName, "Processing Group is mandatory and can't be empty!"); | ||
return service.pause(processorName); | ||
} | ||
|
||
@GetMapping("{method}/reset/{processorName}") | ||
public Mono<Void> reset(@PathVariable("method") EventProcessorService service, @PathVariable String processorName) { | ||
Assert.hasText(processorName, "Processing Group is mandatory and can't be empty!"); | ||
return service.reset(processorName); | ||
} | ||
|
||
} |
5 changes: 4 additions & 1 deletion
5
...n/java/io/axoniq/EventRestController.java → ...xoniq/controller/EventRestController.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
39 changes: 0 additions & 39 deletions
39
reset-handler/src/main/java/io/axoniq/framework/FrameworkEventProcessorRestController.java
This file was deleted.
Oops, something went wrong.
50 changes: 0 additions & 50 deletions
50
reset-handler/src/main/java/io/axoniq/server/ServerEventProcessorRestController.java
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
reset-handler/src/main/java/io/axoniq/service/EventProcessorService.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 io.axoniq.service; | ||
|
||
import reactor.core.publisher.Mono; | ||
|
||
public interface EventProcessorService { | ||
Mono<Void> pause(String processorName); | ||
|
||
Mono<Void> start(String processorName); | ||
|
||
Mono<Void> reset(String processorName); | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not the 4.8 form the bom?