-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multi-language docs examples for client configuration and method exam…
…ples (#836)
- Loading branch information
Showing
17 changed files
with
264 additions
and
55 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
12 changes: 12 additions & 0 deletions
12
...uite-groovy/src/test/groovy/io/micronaut/kafka/docs/producer/config/ClientIdClient.groovy
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.micronaut.kafka.docs.producer.config | ||
|
||
import io.micronaut.configuration.kafka.annotation.KafkaClient | ||
import io.micronaut.context.annotation.Requires | ||
|
||
@Requires(property = 'spec.name', value = 'ClientIdClientTest') | ||
// tag::annotation[] | ||
@KafkaClient('product-client') | ||
// end::annotation[] | ||
interface ClientIdClient { | ||
// define client API | ||
} |
8 changes: 8 additions & 0 deletions
8
test-suite-groovy/src/test/groovy/io/micronaut/kafka/docs/producer/methods/Book.groovy
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,8 @@ | ||
package io.micronaut.kafka.docs.producer.methods | ||
|
||
import groovy.transform.Canonical | ||
|
||
@Canonical | ||
class Book { | ||
String title | ||
} |
30 changes: 30 additions & 0 deletions
30
test-suite-groovy/src/test/groovy/io/micronaut/kafka/docs/producer/methods/BookClient.groovy
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 @@ | ||
package io.micronaut.kafka.docs.producer.methods | ||
|
||
import io.micronaut.configuration.kafka.annotation.KafkaClient | ||
import io.micronaut.configuration.kafka.annotation.KafkaKey | ||
import io.micronaut.configuration.kafka.annotation.Topic | ||
import io.micronaut.context.annotation.Requires | ||
import io.reactivex.Flowable | ||
import io.reactivex.Single | ||
import org.apache.kafka.clients.producer.RecordMetadata | ||
import reactor.core.publisher.Flux | ||
|
||
@Requires(property = 'spec.name', value = 'BookClientTest') | ||
@KafkaClient('product-client') | ||
interface BookClient { | ||
|
||
// tag::single[] | ||
@Topic('my-books') | ||
Single<Book> sendBook(@KafkaKey String author, Single<Book> book); | ||
// end::single[] | ||
|
||
// tag::flowable[] | ||
@Topic('my-books') | ||
Flowable<Book> sendBooks(@KafkaKey String author, Flowable<Book> book); | ||
// end::flowable[] | ||
|
||
// tag::flux[] | ||
@Topic('my-books') | ||
Flux<RecordMetadata> sendBooks(@KafkaKey String author, Flux<Book> book); | ||
// end::flux[] | ||
} |
34 changes: 34 additions & 0 deletions
34
...uite-groovy/src/test/groovy/io/micronaut/kafka/docs/producer/methods/ProductClient.groovy
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,34 @@ | ||
package io.micronaut.kafka.docs.producer.methods | ||
|
||
import io.micronaut.configuration.kafka.annotation.KafkaClient | ||
import io.micronaut.configuration.kafka.annotation.KafkaKey | ||
import io.micronaut.configuration.kafka.annotation.Topic | ||
import io.micronaut.context.annotation.Requires | ||
import io.micronaut.messaging.annotation.MessageHeader | ||
import org.apache.kafka.common.header.Header | ||
import org.apache.kafka.common.header.Headers | ||
|
||
@Requires(property = 'spec.name', value = 'ProductClientTest') | ||
@KafkaClient('product-client') | ||
interface ProductClient { | ||
|
||
// tag::key[] | ||
@Topic('my-products') | ||
void sendProduct(@KafkaKey String brand, String name) | ||
// end::key[] | ||
|
||
// tag::messageheader[] | ||
@Topic('my-products') | ||
void sendProduct(@KafkaKey String brand, String name, @MessageHeader('My-Header') String myHeader) | ||
// end::messageheader[] | ||
|
||
// tag::collectionheaders[] | ||
@Topic('my-bicycles') | ||
void sendBicycle(@KafkaKey String brand, String model, Collection<Header> headers) | ||
// end::collectionheaders[] | ||
|
||
// tag::kafkaheaders[] | ||
@Topic('my-bicycles') | ||
void sendBicycle(@KafkaKey String brand, String model, Headers headers) | ||
// end::kafkaheaders[] | ||
} |
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
12 changes: 12 additions & 0 deletions
12
test-suite-kotlin/src/test/kotlin/io/micronaut/kafka/docs/producer/config/ClientIdClient.kt
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.micronaut.kafka.docs.producer.config | ||
|
||
import io.micronaut.configuration.kafka.annotation.KafkaClient | ||
import io.micronaut.context.annotation.Requires | ||
|
||
@Requires(property = "spec.name", value = "ClientIdClientTest") | ||
// tag::annotation[] | ||
@KafkaClient("product-client") | ||
// end::annotation[] | ||
interface ClientIdClient { | ||
// define client API | ||
} |
3 changes: 3 additions & 0 deletions
3
test-suite-kotlin/src/test/kotlin/io/micronaut/kafka/docs/producer/methods/Book.kt
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,3 @@ | ||
package io.micronaut.kafka.docs.producer.methods | ||
|
||
data class Book(val title: String) |
30 changes: 30 additions & 0 deletions
30
test-suite-kotlin/src/test/kotlin/io/micronaut/kafka/docs/producer/methods/BookClient.kt
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 @@ | ||
package io.micronaut.kafka.docs.producer.methods | ||
|
||
import io.micronaut.configuration.kafka.annotation.KafkaClient | ||
import io.micronaut.configuration.kafka.annotation.KafkaKey | ||
import io.micronaut.configuration.kafka.annotation.Topic | ||
import io.micronaut.context.annotation.Requires | ||
import io.reactivex.Flowable | ||
import io.reactivex.Single | ||
import org.apache.kafka.clients.producer.RecordMetadata | ||
import reactor.core.publisher.Flux | ||
|
||
@Requires(property = "spec.name", value = "BookClientTest") | ||
@KafkaClient("product-client") | ||
interface BookClient { | ||
|
||
// tag::single[] | ||
@Topic("my-books") | ||
fun sendBook(@KafkaKey author: String, book: Single<Book>): Single<Book> | ||
// end::single[] | ||
|
||
// tag::flowable[] | ||
@Topic("my-books") | ||
fun sendBooks(@KafkaKey author: String, book: Flowable<Book>): Flowable<Book> | ||
// end::flowable[] | ||
|
||
// tag::flux[] | ||
@Topic("my-books") | ||
fun sendBooks(@KafkaKey author: String, book: Flux<Book>): Flux<RecordMetadata> | ||
// end::flux[] | ||
} |
34 changes: 34 additions & 0 deletions
34
test-suite-kotlin/src/test/kotlin/io/micronaut/kafka/docs/producer/methods/ProductClient.kt
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,34 @@ | ||
package io.micronaut.kafka.docs.producer.methods | ||
|
||
import io.micronaut.configuration.kafka.annotation.KafkaClient | ||
import io.micronaut.configuration.kafka.annotation.KafkaKey | ||
import io.micronaut.configuration.kafka.annotation.Topic | ||
import io.micronaut.context.annotation.Requires | ||
import io.micronaut.messaging.annotation.MessageHeader | ||
import org.apache.kafka.common.header.Header | ||
import org.apache.kafka.common.header.Headers | ||
|
||
@Requires(property = "spec.name", value = "ProductClientTest") | ||
@KafkaClient("product-client") | ||
interface ProductClient { | ||
|
||
// tag::key[] | ||
@Topic("my-products") | ||
fun sendProduct(@KafkaKey brand: String, name: String) | ||
// end::key[] | ||
|
||
// tag::messageheader[] | ||
@Topic("my-products") | ||
fun sendProduct(@KafkaKey brand: String, name: String, @MessageHeader("My-Header") myHeader: String) | ||
// end::messageheader[] | ||
|
||
// tag::collectionheaders[] | ||
@Topic("my-bicycles") | ||
fun sendBicycle(@KafkaKey brand: String, model: String, headers: Collection<Header>) | ||
// end::collectionheaders[] | ||
|
||
// tag::kafkaheaders[] | ||
@Topic("my-bicycles") | ||
fun sendBicycle(@KafkaKey brand: String, model: String, headers: Headers) | ||
// end::kafkaheaders[] | ||
} |
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
12 changes: 12 additions & 0 deletions
12
test-suite/src/test/java/io/micronaut/kafka/docs/producer/config/ClientIdClient.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.micronaut.kafka.docs.producer.config; | ||
|
||
import io.micronaut.configuration.kafka.annotation.KafkaClient; | ||
import io.micronaut.context.annotation.Requires; | ||
|
||
@Requires(property = "spec.name", value = "ClientIdClientTest") | ||
// tag::annotation[] | ||
@KafkaClient("product-client") | ||
// end::annotation[] | ||
public interface ClientIdClient { | ||
// define client API | ||
} |
7 changes: 7 additions & 0 deletions
7
test-suite/src/test/java/io/micronaut/kafka/docs/producer/methods/Book.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,7 @@ | ||
package io.micronaut.kafka.docs.producer.methods; | ||
|
||
import io.micronaut.serde.annotation.Serdeable; | ||
|
||
@Serdeable | ||
public record Book(String title) { | ||
} |
30 changes: 30 additions & 0 deletions
30
test-suite/src/test/java/io/micronaut/kafka/docs/producer/methods/BookClient.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 @@ | ||
package io.micronaut.kafka.docs.producer.methods; | ||
|
||
import io.micronaut.configuration.kafka.annotation.KafkaClient; | ||
import io.micronaut.configuration.kafka.annotation.KafkaKey; | ||
import io.micronaut.configuration.kafka.annotation.Topic; | ||
import io.micronaut.context.annotation.Requires; | ||
import io.reactivex.Flowable; | ||
import io.reactivex.Single; | ||
import org.apache.kafka.clients.producer.RecordMetadata; | ||
import reactor.core.publisher.Flux; | ||
|
||
@Requires(property = "spec.name", value = "BookClientTest") | ||
@KafkaClient("product-client") | ||
public interface BookClient { | ||
|
||
// tag::single[] | ||
@Topic("my-books") | ||
Single<Book> sendBook(@KafkaKey String author, Single<Book> book); | ||
// end::single[] | ||
|
||
// tag::flowable[] | ||
@Topic("my-books") | ||
Flowable<Book> sendBooks(@KafkaKey String author, Flowable<Book> book); | ||
// end::flowable[] | ||
|
||
// tag::flux[] | ||
@Topic("my-books") | ||
Flux<RecordMetadata> sendBooks(@KafkaKey String author, Flux<Book> book); | ||
// end::flux[] | ||
} |
36 changes: 36 additions & 0 deletions
36
test-suite/src/test/java/io/micronaut/kafka/docs/producer/methods/ProductClient.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,36 @@ | ||
package io.micronaut.kafka.docs.producer.methods; | ||
|
||
import io.micronaut.configuration.kafka.annotation.KafkaClient; | ||
import io.micronaut.configuration.kafka.annotation.KafkaKey; | ||
import io.micronaut.configuration.kafka.annotation.Topic; | ||
import io.micronaut.context.annotation.Requires; | ||
import io.micronaut.messaging.annotation.MessageHeader; | ||
import org.apache.kafka.common.header.Header; | ||
import org.apache.kafka.common.header.Headers; | ||
|
||
import java.util.Collection; | ||
|
||
@Requires(property = "spec.name", value = "ProductClientTest") | ||
@KafkaClient("product-client") | ||
public interface ProductClient { | ||
|
||
// tag::key[] | ||
@Topic("my-products") | ||
void sendProduct(@KafkaKey String brand, String name); | ||
// end::key[] | ||
|
||
// tag::messageheader[] | ||
@Topic("my-products") | ||
void sendProduct(@KafkaKey String brand, String name, @MessageHeader("My-Header") String myHeader); | ||
// end::messageheader[] | ||
|
||
// tag::collectionheaders[] | ||
@Topic("my-bicycles") | ||
void sendBicycle(@KafkaKey String brand, String model, Collection<Header> headers); | ||
// end::collectionheaders[] | ||
|
||
// tag::kafkaheaders[] | ||
@Topic("my-bicycles") | ||
void sendBicycle(@KafkaKey String brand, String model, Headers headers); | ||
// end::kafkaheaders[] | ||
} |