Skip to content

Commit

Permalink
Merge branch 'master' into issue2882
Browse files Browse the repository at this point in the history
  • Loading branch information
otbe committed Jun 13, 2024
2 parents 50f79ee + 58c6bf3 commit 4b7b228
Show file tree
Hide file tree
Showing 44 changed files with 974 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/kts/format.main.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env kotlin

@file:DependsOn("io.github.typesafegithub:github-workflows-kt:2.0.0")
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:2.1.0")


import io.github.typesafegithub.workflows.actions.actions.CheckoutV4
Expand Down
2 changes: 1 addition & 1 deletion .github/kts/maven.main.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env kotlin

@file:DependsOn("io.github.typesafegithub:github-workflows-kt:2.0.0")
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:2.1.0")


import io.github.typesafegithub.workflows.actions.actions.CacheV4
Expand Down
2 changes: 1 addition & 1 deletion .github/kts/ui.main.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env kotlin

@file:DependsOn("io.github.typesafegithub:github-workflows-kt:2.0.0")
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:2.1.0")

import io.github.typesafegithub.workflows.actions.actions.CacheV4
import io.github.typesafegithub.workflows.actions.actions.CheckoutV4
Expand Down
18 changes: 18 additions & 0 deletions factcast-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@
<artifactId>factcast-grpc-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.factcast</groupId>
<artifactId>factcast-grpc-lz4</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.factcast</groupId>
<artifactId>factcast-grpc-snappy</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.factcast</groupId>
<artifactId>factcast-server-grpc</artifactId>
Expand Down Expand Up @@ -151,6 +161,7 @@
<artifactId>guava</artifactId>
<version>33.2.1-jre</version>
</dependency>
<!-- will be deprecated -->
<dependency>
<groupId>net.jpountz.lz4</groupId>
<artifactId>lz4</artifactId>
Expand All @@ -161,6 +172,13 @@
<artifactId>snappy-java</artifactId>
<version>1.1.10.5</version>
</dependency>
<!-- /will be deprecated -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.26.2</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
Expand Down
5 changes: 3 additions & 2 deletions factcast-client-grpc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<groupId>net.devh</groupId>
<artifactId>grpc-client-spring-boot-starter</artifactId>
</dependency>
<!-- deprecated, will be removed -->
<dependency>
<groupId>net.jpountz.lz4</groupId>
<artifactId>lz4</artifactId>
Expand All @@ -79,11 +80,11 @@
<artifactId>snappy-java</artifactId>
<optional>true</optional>
</dependency>
<!--/deprecated -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.26.2</version>
<scope>test</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import net.jpountz.lz4.*;

@GrpcCodec(advertised = true, codecType = CodecType.ALL)
@Deprecated
public class Lz4GrpcClientCodec implements Codec {
private static final LZ4FastDecompressor decomp = LZ4Factory.fastestInstance().fastDecompressor();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
import org.xerial.snappy.SnappyInputStream;
import org.xerial.snappy.SnappyOutputStream;

@SuppressWarnings("DeprecatedIsStillUsed")
@GrpcCodec(advertised = true, codecType = CodecType.ALL)
@Deprecated
public class SnappyGrpcClientCodec implements Codec {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.IOException;
import org.junit.jupiter.api.Test;

@SuppressWarnings("deprecation")
class Lz4GrpcClientCodecTest {

final Lz4GrpcClientCodec uut = new Lz4GrpcClientCodec();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.IOException;
import org.junit.jupiter.api.Test;

@SuppressWarnings("deprecation")
class SnappyGrpcClientCodecTest {

final SnappyGrpcClientCodec uut = new SnappyGrpcClientCodec();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@

import java.util.Optional;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.factcast.core.store.FactStore;

@RequiredArgsConstructor
@Deprecated
@Slf4j
public class FactCastSnapshotCache implements SnapshotCache {

@NonNull final FactStore store;
@NonNull private final FactStore store;

public FactCastSnapshotCache(@NonNull FactStore store) {
this.store = store;
//noinspection deprecation
log.warn(
"You configured factus to use the default FactCastSnapshotCache instead of a client-local cache. This implemenation is deprecated and will be removed soon. Please consider alternative SnapshotCache implementations (like factcast-snapshotcache-redisson for instance).");
}

@Override
public @NonNull Optional<Snapshot> getSnapshot(@NonNull SnapshotId id) {
Expand Down
2 changes: 1 addition & 1 deletion factcast-factus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
<version>1.13.0</version>
<version>1.13.1</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ public class CompressionCodecs {

private final String orderedListOfAvailableCodecsAsString;

// lz4c/snappyc originate from commons.compress, see dedicated modules.
private static final String[] AVAIL_CODECS = {"lz4c", "snappyc", "lz4", "snappy", "gzip"};

public CompressionCodecs() {
orderedListOfAvailableCodecs =
Stream.of("lz4", "snappy", "gzip")
Stream.of(AVAIL_CODECS)
.filter(CompressionCodecs::locallyAvailable)
.collect(Collectors.toList());
orderedListOfAvailableCodecsAsString = String.join(",", orderedListOfAvailableCodecs);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright © 2017-2024 factcast.org
*
* 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
*
* http://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 org.factcast.grpc.api;

import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;

import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
class CompressionCodecsTest {

@InjectMocks private CompressionCodecs underTest;

@Nested
class WhenSelectingFrom {

@BeforeEach
void setup() {}

@Test
void selectsGzipIfThisIsTheOnlyAvail() {
Assertions.assertThat(underTest.selectFrom("a ,b , gzip, snappy ")).hasValue("gzip");
}
}

@Nested
class WhenAvailabling {
@Test
void avail() {
Assertions.assertThat(underTest.available()).isEqualTo("gzip");
}
}
}
102 changes: 102 additions & 0 deletions factcast-grpc-lz4/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.factcast</groupId>
<artifactId>factcast</artifactId>
<version>0.7.9-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>factcast-grpc-lz4</artifactId>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.factcast</groupId>
<artifactId>factcast-internal-dep</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.devh</groupId>
<artifactId>grpc-client-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
</dependency>
<dependency>
<groupId>org.factcast</groupId>
<artifactId>factcast-core</artifactId>
</dependency>
<dependency>
<groupId>org.factcast</groupId>
<artifactId>factcast-core</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
</dependency>
</dependencies>
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.7.1</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/java</source>
<source>${project.build.directory}/generated-sources/grpc-java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright © 2017-2020 factcast.org
*
* 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
*
* http://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 org.factcast.grpc.lz4;

import io.grpc.Codec;
import java.io.InputStream;
import java.io.OutputStream;
import lombok.SneakyThrows;
import net.devh.boot.grpc.common.codec.CodecType;
import net.devh.boot.grpc.common.codec.GrpcCodec;
import org.apache.commons.compress.compressors.lz4.FramedLZ4CompressorInputStream;
import org.apache.commons.compress.compressors.lz4.FramedLZ4CompressorOutputStream;

@GrpcCodec(advertised = true, codecType = CodecType.ALL)
public class Lz4cGrpcClientCodec implements Codec {

@Override
public String getMessageEncoding() {
return "lz4c";
}

@SneakyThrows
@Override
public InputStream decompress(InputStream inputStream) {
return new FramedLZ4CompressorInputStream(inputStream);
}

@SneakyThrows
@Override
public OutputStream compress(OutputStream outputStream) {
return new FramedLZ4CompressorOutputStream(outputStream);
}
}
Loading

0 comments on commit 4b7b228

Please sign in to comment.