Skip to content
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

Merge 1.2.x into master #80

Merged
merged 36 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
dcc173c
use Gradle Kotlin DSL
sdelamo Nov 21, 2022
9fb7f04
Update slsa-framework/slsa-github-generator action to v1.3.0 (#42)
renovate[bot] Nov 21, 2022
b4564fd
ci: distribution temurin cla provenance (#44)
micronaut-build Nov 21, 2022
a740f04
Update stefanzweifel/git-auto-commit-action action to v4.15.4 (#43)
renovate[bot] Nov 21, 2022
d2c64da
build: Micronaut Framework 3.7.4
sdelamo Nov 21, 2022
1ae8b9e
build: spock 2.2-groovy-3.0
sdelamo Nov 21, 2022
d0e7a3c
doc: eager singletons and inject HttpClient (#66)
timyates Feb 23, 2023
a0db518
ci: projectVersion 1.2.0-SNAPSHOT
sdelamo Feb 24, 2023
0b2ed9a
ci: githubCoreBranch 3.9.x
sdelamo Feb 24, 2023
f89af8f
build: Micronaut Framework 3.8.5
sdelamo Feb 24, 2023
332ae61
build: Micronaut Test 3.8.2
sdelamo Feb 24, 2023
977c717
build: Spock 2.3-groovy-3.0
sdelamo Feb 24, 2023
b307366
wip DataSourceResolver
sdelamo Mar 1, 2023
1299861
Convert Delegating datasource and filter non-hikari contents
timyates Mar 1, 2023
0f099df
Test
timyates Mar 1, 2023
36d9315
Test to ensure DBCP still works and isn't supported
timyates Mar 1, 2023
0838e48
Try to downgrade Jooq
timyates Mar 1, 2023
61f2e5e
remove @Inject BeanContext ctx
sdelamo Mar 3, 2023
085fafe
Simplify composite (#73)
sdelamo Mar 3, 2023
4758b1f
Merge pull request #72 from micronaut-projects/jooq
timyates Mar 3, 2023
2e2e2a4
build: Micronaut Framework 3.8.6
sdelamo Mar 6, 2023
0b20627
build: Micronaut Test 3.9.1
sdelamo Mar 6, 2023
5fa50cd
ci: GitHub Actions sync
sdelamo Mar 6, 2023
db94f4e
[skip ci] Release v1.2.0
micronaut-build Mar 6, 2023
b2f39f3
Back to 1.2.1-SNAPSHOT
micronaut-build Mar 6, 2023
79fabc2
Redis support for CRaC (#78)
timyates Mar 23, 2023
56209fd
[skip ci] Release v1.2.1
micronaut-build Mar 23, 2023
30012d3
Back to 1.2.2-SNAPSHOT
micronaut-build Mar 23, 2023
f838b8e
Merge branch '1.2.x' into mergeup-1.2.x
timyates Mar 23, 2023
4fa7c92
Fix build with missing dependencies
timyates Mar 23, 2023
e2ed723
Typesafe project accessors
timyates Mar 23, 2023
4d905ff
remove constructor deprecated in 1.2
timyates Mar 23, 2023
aa4ecf1
Reinstate javadoc
timyates Mar 23, 2023
1214771
Update libs.versions.toml
sdelamo Mar 28, 2023
4b798c0
Update build.gradle.kts
sdelamo Mar 28, 2023
4cd73ca
Update build.gradle.kts
sdelamo Mar 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions .github/workflows/files-sync.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: Files sync
on:
push:
branches:
- master
schedule:
- cron: '0 5 * * *'
jobs:
sync-files:
if: github.repository == 'micronaut-projects/micronaut-project-template'
Expand All @@ -22,6 +21,7 @@ jobs:
- coherence
- core
- couchbase
- crac
- data
- discovery-client
- elasticsearch
Expand Down Expand Up @@ -52,6 +52,7 @@ jobs:
- openapi
- oracle-cloud
- picocli
- platform
- problem-json
- pulsar
- r2dbc
Expand All @@ -64,6 +65,7 @@ jobs:
- security
- serialization
- servlet
- session
- spring
- sql
- test
Expand All @@ -90,21 +92,23 @@ jobs:
run: |
branch=$(git rev-parse --abbrev-ref HEAD)
echo "Current branch: ${branch}"
echo ::set-output name=branch::${branch}
echo "branch=${branch}" >> $GITHUB_OUTPUT
- name: Sync workflows
run: |
mkdir -p target/.github/workflows/
rsync --verbose --verbose --archive -F "source/.github/workflows/" "target/.github/workflows/"
rm -f target/.github/dependabot.yml
rm -f target/.github/stale.yml
rm -f target/.github/release-drafter.yml
rm -f target/.github/workflows/release-notes.yml
rm -f target/.github/workflows/dependency-update.yml
- name: Copy files from source to target branches
run: |
while IFS= read -r file; do
dest="$(dirname $file)"
mkdir -p target/$dest
cp -r source/$file target/$dest
dest_dirname="$(dirname $file)"
dest_filename="$(basename $file)"
mkdir -p target/$dest_dirname
[ ! -f target/${dest_dirname}/${dest_filename}.lock ] && cp source/$file target/${dest_dirname}/${dest_filename}
done <<< "$FILES"
env:
FILES: |-
Expand All @@ -117,15 +121,20 @@ jobs:
.github/ISSUE_TEMPLATE/config.yml
.github/ISSUE_TEMPLATE/new_feature.yaml
.github/ISSUE_TEMPLATE/other.yaml
gradle/wrapper/*
gradlew*
gradle/wrapper/gradle-wrapper.jar
gradle/wrapper/gradle-wrapper.properties
gradlew
gradlew.bat
MAINTAINING.md
SECURITY.md
LICENSE
config/HEADER
config/spotless.license.java
config/checkstyle/checkstyle.xml
config/checkstyle/suppressions.xml
- name: Sleep for 3 minutes to avoid rate limiting
run: sleep 180s
shell: bash
- name: Create Pull Request - ${{ steps.branch.outputs.branch }}
uses: peter-evans/create-pull-request@v4
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ jobs:
- name: "📦 Publish to Sonatype Snapshots"
if: success() && github.event_name == 'push' && matrix.java == '17'
env:
GH_TOKEN_PUBLIC_REPOS_READONLY: ${{ secrets.GH_TOKEN_PUBLIC_REPOS_READONLY }}
GH_USERNAME: ${{ secrets.GH_USERNAME }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
run: ./gradlew publishToSonatype docs --no-daemon
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins {
id("io.micronaut.build.internal.module")
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
plugins {
id "io.micronaut.build.internal.module"
id("io.micronaut.build.internal.crac-base")
}

dependencies {
api(libs.managed.crac)
compileOnly(mn.micronaut.http.server.netty)
compileOnly(mnSql.micronaut.jdbc.hikari)
compileOnly(mnData.micronaut.data.tx)
compileOnly(mnRedis.micronaut.redis.lettuce)

testImplementation(mnData.micronaut.data.tx)
testImplementation(mnSql.micronaut.jdbc.hikari)
testImplementation(mnSerde.micronaut.serde.jackson)
testImplementation(mn.micronaut.http.server.netty)
testImplementation(mn.micronaut.http.client)
testImplementation(mn.groovy.sql)
testImplementation(mn.logback.classic)
testRuntimeOnly(mnSql.h2)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
repositories {
mavenCentral()
}

dependencies {
testImplementation(libs.managed.crac)

testAnnotationProcessor(mn.micronaut.inject.java)
testImplementation(mn.micronaut.http.client)
testImplementation(mn.micronaut.http.server.netty)

testRuntimeOnly(mn.logback.classic)
testRuntimeOnly(mn.micronaut.jackson.databind)
}

test {
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@
*/
package io.micronaut.crac.resources;

import com.zaxxer.hikari.HikariDataSource;
import io.micronaut.context.annotation.EachBean;
import io.micronaut.context.annotation.Requires;
import io.micronaut.core.annotation.Experimental;
import io.micronaut.crac.CracConfiguration;
import io.micronaut.crac.CracEventPublisher;
import io.micronaut.crac.CracResourceRegistrar;
import io.micronaut.crac.OrderedResource;
import io.micronaut.crac.resources.datasources.HikariDataSourceResource;
import io.micronaut.crac.resources.datasources.UnknownDataSourceResource;
import io.micronaut.transaction.jdbc.DelegatingDataSource;
import io.micronaut.crac.resources.datasources.resolver.DataSourceResourceResolver;
import org.crac.Context;
import org.crac.Resource;
import org.slf4j.Logger;
Expand All @@ -49,36 +47,33 @@ public class DataSourceResource implements OrderedResource {

private final CracEventPublisher eventPublisher;
private final Resource handler;
private final DataSourceResourceResolver dataSourceResolver;

/**
*
* @param configuration
* @param eventPublisher
* @param dataSource
* @param dataSourceResolver
*/
public DataSourceResource(
CracConfiguration configuration,
CracEventPublisher eventPublisher,
DataSource dataSource
DataSource dataSource,
DataSourceResourceResolver dataSourceResolver
) {
this.eventPublisher = eventPublisher;
this.dataSourceResolver = dataSourceResolver;
this.handler = getHandler(dataSource, configuration);
}

private Resource getHandler(DataSource dataSource, CracConfiguration configuration) {
if (dataSource instanceof DelegatingDataSource) {
if (LOG.isDebugEnabled()) {
LOG.debug("DelegatingDataSource detected, unwrapping");
return dataSourceResolver.resolve(dataSource, configuration).orElseGet(() -> {
if (LOG.isWarnEnabled()) {
LOG.warn("DataSource {} is not currently supported by CRaC", dataSource.getClass().getName());
}
dataSource = DelegatingDataSource.unwrapDataSource(dataSource);
if (LOG.isDebugEnabled()) {
LOG.debug("Unwrapped DataSource is {}", dataSource.getClass().getName());
}
}
if (dataSource instanceof HikariDataSource) {
if (LOG.isDebugEnabled()) {
LOG.debug("HikariDataSource detected, using HikariDataSourceResource");
}
return new HikariDataSourceResource((HikariDataSource) dataSource, configuration);
}
if (LOG.isWarnEnabled()) {
LOG.warn("DataSource {} is not currently supported by CRaC", dataSource.getClass().getName());
}
return new UnknownDataSourceResource(dataSource);
return new UnknownDataSourceResource(dataSource);
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 2017-2023 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micronaut.crac.resources.datasources.resolver;

import io.micronaut.context.annotation.Primary;
import io.micronaut.core.annotation.Experimental;
import io.micronaut.core.annotation.NonNull;
import io.micronaut.crac.CracConfiguration;
import jakarta.inject.Singleton;
import org.crac.Resource;

import javax.sql.DataSource;
import java.util.List;
import java.util.Optional;

/**
* Composite DataSourceResolver that delegates to a list of resolvers.
*
* @author Tim Yates
* @since 1.2.0
*/
@Primary
@Singleton
@Experimental
public class CompositeDataSourceResolver implements DataSourceResourceResolver {

private final List<DataSourceResourceResolver> resolvers;

public CompositeDataSourceResolver(List<DataSourceResourceResolver> resolvers) {
this.resolvers = resolvers;
}

@Override
@NonNull
public Optional<Resource> resolve(@NonNull DataSource dataSource, @NonNull CracConfiguration configuration) {
return resolvers.stream()
.map(resolver -> resolver.resolve(dataSource, configuration))
.filter(Optional::isPresent)
.map(Optional::get)
.findFirst();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2017-2023 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micronaut.crac.resources.datasources.resolver;

import io.micronaut.core.annotation.NonNull;
import io.micronaut.core.order.Ordered;
import io.micronaut.crac.CracConfiguration;
import org.crac.Resource;

import javax.sql.DataSource;
import java.util.Optional;

/**
* Interface to allow DataSource resolution.
*
* @author Tim Yates
* @since 1.2.0
*/
@FunctionalInterface
public interface DataSourceResourceResolver extends Ordered {

@NonNull
Optional<Resource> resolve(@NonNull DataSource dataSource, @NonNull CracConfiguration configuration);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright 2017-2023 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micronaut.crac.resources.datasources.resolver;

import com.zaxxer.hikari.HikariDataSource;
import io.micronaut.context.annotation.Requires;
import io.micronaut.core.annotation.Experimental;
import io.micronaut.core.annotation.NonNull;
import io.micronaut.crac.CracConfiguration;
import io.micronaut.crac.resources.datasources.HikariDataSourceResource;
import io.micronaut.transaction.jdbc.DelegatingDataSource;
import jakarta.inject.Singleton;
import org.crac.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.sql.DataSource;
import java.util.Optional;

/**
* If the data Source is of type {@link DelegatingDataSource}, extract the underlying data source.
*
* @author Sergio del Amo
* @since 1.2.0
*/
@Singleton
@Experimental
@Requires(classes = HikariDataSource.class, missing = { DelegatingDataSource.class })
public class HikariDataSourceResolver implements DataSourceResourceResolver {

static final int ORDER = 1;

private static final Logger LOG = LoggerFactory.getLogger(HikariDataSourceResolver.class);

@Override
@NonNull
public Optional<Resource> resolve(@NonNull DataSource dataSource, @NonNull CracConfiguration configuration) {
return resourceForNonDelegatingDataSource(dataSource, configuration);
}

static Optional<Resource> resourceForNonDelegatingDataSource(DataSource dataSource, CracConfiguration configuration) {
return dataSource instanceof HikariDataSource ?
Optional.of(dataSource).map(ds -> {
if (LOG.isDebugEnabled()) {
LOG.debug("HikariDataSource detected, using HikariDataSourceResource");
}
return new HikariDataSourceResource((HikariDataSource) ds, configuration);
}) : Optional.empty();
}

@Override
public int getOrder() {
return ORDER;
}
}
Loading