Skip to content

Commit

Permalink
Quarkus 1.7.0 (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
lordofthejars authored Aug 20, 2020
1 parent 1cef341 commit c1e92b7
Show file tree
Hide file tree
Showing 11 changed files with 1,290 additions and 62 deletions.
687 changes: 659 additions & 28 deletions docs/index.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/quarkus-cheat-sheet/attributes.adoc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
:logo: quarkus.png
:version: 1.6.0.Final
:version: 1.7.0.Final
:source-highlighter: highlightjs
:sectlinks:
:linkattrs:
:sectanchors:
:toc: macro
:nofooter:
:pdf-download: https://github.com/lordofthejars/quarkus-cheat-sheet/releases/download/1.0.18/quarkus-cheat-sheet.pdf
:pdf-download: https://github.com/lordofthejars/quarkus-cheat-sheet/releases/download/1.0.19/quarkus-cheat-sheet.pdf
28 changes: 24 additions & 4 deletions examples/quarkus-cheat-sheet/cloud.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,11 @@ Also, you can customize the generated resource by setting the new values in `app

[source, properties]
----
quarkus.kubernetes.namespace=mynamespace
quarkus.kubernetes.replicas=3
quarkus.kubernetes.labelsfoo=bar
quarkus.kubernetes.labels.foo=bar
quarkus.kubernetes.readiness-probe.period-seconds=45
Expand Down Expand Up @@ -283,6 +285,19 @@ quarkus.kubernetes.annotations.foo=bar
----
// end::update_14_38[]

// tag::update_18_3[]
*metrics*

When using metrics extension, Prometheus annotations are generated:

[source, yaml]
----
prometheus.io/scrape: "true"
prometheus.io/path: /metrics
prometheus.io/port: "8080"
----
// end::update_18_3[]

*Kubernetes Deployment Targets*
// tag::update_12_4[]

Expand Down Expand Up @@ -358,7 +373,7 @@ Instead of adding Kubernetes extension, set container image s2i and the `target`

// tag::update_15_14[]

Integration between MicroProfile Config spec and ConfigMaps:
Integration between MicroProfile Config spec and ConfigMaps & Secrets:

[source, bash]
----
Expand Down Expand Up @@ -396,10 +411,15 @@ The application will not start if any of the configured config sources cannot be
`config-maps`::
ConfigMaps to look for in the namespace that the Kubernetes Client has been configured for. Supports CSV.

`secrets`::
Secrets to look for in the namespace that the Kubernetes Client has been configured for. Supports CSV.
`namespace`::
Access to ConfigMaps from a specific namespace.
// end::update_15_14[]

// tag::update_18_10[]
`secrets.enabled`::
Whether or not configuration can be read from secrets. (default: `false`)
// end::update_18_10[]

== Kubernetes Client
// tag::update_4_5[]
Quarkus integrates with https://github.com/fabric8io/kubernetes-client[Fabric8 Kubernetes Client, window="_blank"].
Expand Down
81 changes: 79 additions & 2 deletions examples/quarkus-cheat-sheet/core.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,29 @@ NOTE: Properties set at runtime have absolutely no effect on the bean resolution

// end::update_16_1[]

// tag::update_18_8[]
*Container-managed Concurrency*

Quarkus provides `@io.quarkus.arc.Lock` and a built-in interceptor for concurrency control.

[source, java]
----
@Lock
@ApplicationScoped
class SharedService {
void addAmount(BigDecimal amout) {
}
@Lock(value = Lock.Type.READ, time = 1, unit = TimeUnit.SECONDS)
BigDecimal getAmount() {
}
}
----

By default the class is in write mode (so no concurrent calls allowed) except when lock type is `READ` where the method can be called concurrently if no write operation in process.
// end::update_18_8[]

== JSON Marshalling/Unmarshalling

To work with `JSON-B` you need to add a dependency:
Expand All @@ -819,8 +842,6 @@ public class Sauce {
}
----

<<<

JSON equivalent:

[source, json]
Expand Down Expand Up @@ -1503,6 +1524,62 @@ You can also inject the URL where Quarkus is started:
URL url;
----

// tag::update_18_9[]
[source, java]
----
@TestHTTPEndpoint(GreetingResource.class)
@TestHTTPResource
URL url;
----

[source, java]
----
@QuarkusTest
@TestHTTPEndpoint(GreetingResource.class)
public class GreetingResourceTest {
@Test
public void testHelloEndpoint() {
given()
.when().get()
.then()
.statusCode(200)
.body(is("hello"));
}
}
----

Root path is calculated automatically, not necessary to explicitly set.
// end::update_18_9[]

*QuarkusTestProfile*

// tag::update_18_5[]
You can define for each Test class a different configuration options.

IMPORTANT: This implies that the Quarkus service is restarted.

[source, java]
----
public class MyProfile implements io.quarkus.test.junit.QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("greetings.message", "This is a Test");
}
@Override
public String getConfigProfile() {
return "my-test-profile";
}
}
@QuarkusTest
@TestProfile(MyProfile.class)
public class MyTestClass {
}
----
// end::update_18_5[]

*Quarkus Test Resource*

// tag::update_4_2[]
Expand Down
12 changes: 9 additions & 3 deletions examples/quarkus-cheat-sheet/misc.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ Templates can be defined in any format, in case of HTML:
</head>
<body>
<h1>{item.name ?: 'Unknown'}</h1>
<h2>{str:reverse('Hello')}</h2>
<div>Price: {item.price}</div>
{#if item.price > 100}
<div>Discounted Price: {item.discountedPrice}</div>
Expand Down Expand Up @@ -616,6 +617,13 @@ public TemplateInstance get(@PathParam("id") Integer id) {
static BigDecimal discountedPrice(Item item) {
return item.price.multiply(new BigDecimal("0.9"));
}
@TemplateExtension(namespace = "str")
public static class StringExtensions {
static String reverse(String val) {
return new StringBuilder(val).reverse().toString();
}
}
----

If `@ResourcePath` is not used in `Template` then the name of the field is used as file name.
Expand Down Expand Up @@ -712,7 +720,7 @@ String output = report
[source, java]
----
CompletionStage<String> async = report.renderAsync();
Publisher<String> publisher = report.publisher();
Multi<String> publisher = report.createMulti();
Uni<String> content = io.smallrye.mutiny.Uni.createFrom()
.completionStage(() -> report.renderAsync());
Expand Down Expand Up @@ -808,8 +816,6 @@ Quarkus can cache method calls by using as key the tuple (method + arguments).
public String getDailyForecast(LocalDate date, String city) {}
----

<<<

`@CacheInvalidate` removes the element represented by the calculated cache key from cache.
`@CacheInvalidateAll` removes all entries from the cache.
`@CacheKey` to specifically set the arguments to be used as key instead of all.
Expand Down
15 changes: 14 additions & 1 deletion examples/quarkus-cheat-sheet/network.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ The maximum length of all headers. (default: `20k`)
The maximum size of a request body. (default: `10M`)

`limits.max-chunk-size`::
The max HTTP chunk size
The max HTTP chunk size.

`limits.max-initial-line-length`::
The maximum length of the initial line. (default: `4096`)

`idle-timeout`::
Http connection idle timeout. (default: `30M`)
Expand Down Expand Up @@ -430,6 +433,15 @@ public class MyDeclarativeRoutes {
rc.response().putHeader("X-Filter", "filter 2");
rc.next();
}
@Route
String hello(@Param Optional<String> name) {}
@Route
String helloFromHeader(@Header("My-Header") String header) {}
@Route
String createPerson(@Body Person person) {}
}
----
Expand Down Expand Up @@ -906,6 +918,7 @@ kafka-streams:: Liveness (for stream state) and Readiness (topics created) probe
vault:: A probe to check Vault conection status.
gRPC:: A readiness probe for the gRPC services.
Cassandra:: A readiness probe to check Cassandra connection status.
Redis:: A readiness probe to check Redis connection status.

You can disable the automatic generation by setting `<component>.health.enabled` to false.

Expand Down
96 changes: 95 additions & 1 deletion examples/quarkus-cheat-sheet/persistence.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ List of datasource parameters.
`quarkus.datasource` as prefix is skipped in the next table.
`db-kind`::
Built-in datasource kinds so the JDBC driver is resolved automatically. Possible values: `derby`, `h2`, `mariadb`, `mssql`, `mysql`, `postgresql`.
Built-in datasource kinds so the JDBC driver is resolved automatically. Possible values: `derby`, `h2`, `mariadb`, `mssql`, `mysql`, `postgresql`, `db2`.
`username`::
Username to access.
Expand Down Expand Up @@ -624,6 +624,18 @@ quarkus.flyway.mycompany.locations=classpath:database/mycompany
If you need more dynamic approach implement: `@ApplicationScoped io.quarkus.hibernate.orm.runtime.tenant.TenantConnectionResolver`
// end::update_16_14[]

== Hibernate Envers

// tag::update_18_1[]
Quarkus supports Hibernate Envers.

[source, bash]
----
./mvnw quarkus:add-extension
-Dextensions="hibernate-envers"
----
// end::update_18_1[]

== REST Data Panache

// tag::update_16_21[]
Expand Down Expand Up @@ -888,6 +900,80 @@ org.infinispan.manager.EmbeddedCacheManager cacheManager;
----
// end::update_10_7[]

== Redis

// tag::update_18_4[]
Quarkus integrates with Redis.

[source, bash]
----
./mvnw quarkus:add-extension
-Dextensions="redis-client"
----

Configure Redis location:

[source, properties]
----
quarkus.redis.hosts=localhost:6379
----

You can use synchronous or reactive clients:

[source, java]
----
@Inject
RedisClient redisClient;
@Inject
ReactiveRedisClient reactiveRedisClient;
----

[source, java]
----
void increment(String key, Integer incrementBy) {
redisClient.incrby(key, incrementBy.toString());
}
Uni<List<String>> keys() {
return reactiveRedisClient
.keys("*")
.map(response -> {
List<String> result = new ArrayList<>();
for (Response r : response) {
result.add(r.toString());
}
return result;
});
}
----

List of Redis parameters.

`quarkus.redis` as prefix is skipped in the next table.

`health.enabled`::
Health check is published in case the smallrye-health extension is present. (default: `true`)

`password`::
The Redis password.

`hosts`::
The Redis hosts. (default: `localhost:6379`)

`database`::
The Redis database.

`timeout`::
The maximum delay to wait before a blocking command to redis server times out. (default: `10s`)

`ssl`::
Enables or disables the SSL on connect.

`clinet-type`::
The Redis client type. Possible values: `standalone`, `cluster`, `sentinel` (default: `standalone`)
// end::update_18_4[]

== Flyway

// tag::update_1_7[]
Expand Down Expand Up @@ -961,6 +1047,14 @@ Description to tag an existing schema with when executing baseline (default: `Fl
Validate the applied migrations against the available ones (default: `true`)
// end::update_13_6[]

// tag::update_18_6[]
`placeholder-prefix`::
Prefix of every placeholder (default: `${`)

`placeholder-suffix`::
Suffix of every placeholder (default: `}`)
// end::update_18_6[]

*Multiple Datasources*
// tag::update_12_7[]

Expand Down
Loading

0 comments on commit c1e92b7

Please sign in to comment.