-
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/align cloudstream example (#464)
* chore(cloud-stream): align example * chore(cloud-stream): fix cloud-stream message description the description is part of the schema, therefore removing the duplicate in the message (aligns with other plugins)
- Loading branch information
Showing
13 changed files
with
142 additions
and
136 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
23 changes: 0 additions & 23 deletions
23
...ub/stavshamir/springwolf/example/cloudstream/SpringwolfCloudstreamExampleApplication.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,36 +1,13 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.stavshamir.springwolf.example.cloudstream; | ||
|
||
import io.github.stavshamir.springwolf.example.cloudstream.payload.ConsumerPayload; | ||
import io.github.stavshamir.springwolf.example.cloudstream.payload.InputPayload; | ||
import io.github.stavshamir.springwolf.example.cloudstream.payload.OutputPayload; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.kafka.streams.kstream.KStream; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.annotation.Bean; | ||
|
||
import java.util.function.Consumer; | ||
import java.util.function.Function; | ||
|
||
@SpringBootApplication | ||
@Slf4j | ||
public class SpringwolfCloudstreamExampleApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(SpringwolfCloudstreamExampleApplication.class, args); | ||
} | ||
|
||
@Bean | ||
public Function<KStream<Void, InputPayload>, KStream<Void, OutputPayload>> process() { | ||
return input -> input.peek((k, v) -> log.info("Received payload: {}", v)) | ||
.mapValues( | ||
v -> new OutputPayload(v.getFoo().stream().findFirst().orElse("list was empty"), v.getBar())) | ||
.peek((k, v) -> log.info("Publishing output: {}", v)); | ||
} | ||
|
||
@Bean | ||
public Consumer<ConsumerPayload> consumerMethod() { | ||
return input -> log.info("Consumed: {}", input); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...hub/stavshamir/springwolf/example/cloudstream/configuration/CloudstreamConfiguration.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,28 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.stavshamir.springwolf.example.cloudstream.configuration; | ||
|
||
import io.github.stavshamir.springwolf.example.cloudstream.dtos.AnotherPayloadDto; | ||
import io.github.stavshamir.springwolf.example.cloudstream.dtos.ExamplePayloadDto; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.kafka.streams.kstream.KStream; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import java.util.function.Consumer; | ||
import java.util.function.Function; | ||
|
||
@Slf4j | ||
@Configuration | ||
public class CloudstreamConfiguration { | ||
@Bean | ||
public Function<KStream<Void, ExamplePayloadDto>, KStream<Void, AnotherPayloadDto>> process() { | ||
return input -> input.peek((k, v) -> log.info("Received new message in example-topic: {}", input)) | ||
.mapValues(v -> new AnotherPayloadDto("foo", v)) | ||
.peek((k, v) -> log.info("Publishing output: {}", v)); | ||
} | ||
|
||
@Bean | ||
public Consumer<AnotherPayloadDto> consumerMethod() { | ||
return input -> log.info("Received new message in another-topic: {}", input.toString()); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...main/java/io/github/stavshamir/springwolf/example/cloudstream/dtos/AnotherPayloadDto.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 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.stavshamir.springwolf.example.cloudstream.dtos; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.NOT_REQUIRED; | ||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; | ||
|
||
@Schema(description = "Another payload model") | ||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class AnotherPayloadDto { | ||
|
||
@Schema(description = "Foo field", example = "bar", requiredMode = NOT_REQUIRED) | ||
private String foo; | ||
|
||
@Schema(description = "Example field", requiredMode = REQUIRED) | ||
private ExamplePayloadDto example; | ||
} |
30 changes: 30 additions & 0 deletions
30
...main/java/io/github/stavshamir/springwolf/example/cloudstream/dtos/ExamplePayloadDto.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,30 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.stavshamir.springwolf.example.cloudstream.dtos; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; | ||
|
||
@Schema(description = "Example payload model") | ||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class ExamplePayloadDto { | ||
@Schema(description = "Some string field", example = "some string value", requiredMode = REQUIRED) | ||
private String someString; | ||
|
||
@Schema(description = "Some long field", example = "5") | ||
private long someLong; | ||
|
||
@Schema(description = "Some enum field", example = "FOO2", requiredMode = REQUIRED) | ||
private ExampleEnum someEnum; | ||
|
||
public enum ExampleEnum { | ||
FOO1, | ||
FOO2, | ||
FOO3 | ||
} | ||
} |
14 changes: 0 additions & 14 deletions
14
...ain/java/io/github/stavshamir/springwolf/example/cloudstream/payload/ConsumerPayload.java
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
...c/main/java/io/github/stavshamir/springwolf/example/cloudstream/payload/InputPayload.java
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
.../main/java/io/github/stavshamir/springwolf/example/cloudstream/payload/OutputPayload.java
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.