-
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.
chore: Split ChannelScanner and OperationScanner (#562)
- Loading branch information
Showing
46 changed files
with
2,147 additions
and
784 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
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
42 changes: 42 additions & 0 deletions
42
...core/src/main/java/io/github/stavshamir/springwolf/asyncapi/DefaultOperationsService.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,42 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.stavshamir.springwolf.asyncapi; | ||
|
||
import io.github.stavshamir.springwolf.asyncapi.scanners.channels.OperationMerger; | ||
import io.github.stavshamir.springwolf.asyncapi.scanners.channels.OperationsScanner; | ||
import io.github.stavshamir.springwolf.asyncapi.v3.model.operation.Operation; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Service to detect AsyncAPI operations in the current spring context. | ||
*/ | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class DefaultOperationsService implements OperationsService { | ||
|
||
private final List<? extends OperationsScanner> operationScanners; | ||
|
||
/** | ||
* Collects all AsyncAPI Operation using the available {@link OperationsScanner} | ||
* beans. | ||
* @return Map of operation names mapping to detected Operation | ||
*/ | ||
@Override | ||
public Map<String, Operation> findOperations() { | ||
List<Map.Entry<String, Operation>> foundOperations = new ArrayList<>(); | ||
|
||
for (OperationsScanner scanner : operationScanners) { | ||
try { | ||
Map<String, Operation> channels = scanner.scan(); | ||
foundOperations.addAll(channels.entrySet()); | ||
} catch (Exception e) { | ||
log.error("An error was encountered during operation scanning with {}: {}", scanner, e.getMessage(), e); | ||
} | ||
} | ||
return OperationMerger.mergeOperations(foundOperations); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...ngwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/OperationsService.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,19 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.stavshamir.springwolf.asyncapi; | ||
|
||
import io.github.stavshamir.springwolf.asyncapi.v3.model.operation.Operation; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Service to detect AsyncAPI channels in the current spring context. | ||
*/ | ||
public interface OperationsService { | ||
|
||
/** | ||
* Detects all available AsyncAPI Operation in the spring context. | ||
* | ||
* @return Map of operation names mapping to detected Operations | ||
*/ | ||
Map<String, Operation> findOperations(); | ||
} |
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
Oops, something went wrong.