Skip to content

Commit

Permalink
add fury builder options (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
chaokunyang authored Nov 6, 2024
1 parent 91d89e3 commit 1f1e673
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
36 changes: 36 additions & 0 deletions runtime/src/main/java/io/quarkiverse/fury/FuryBuildTimeConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.util.Map;
import java.util.Optional;

import org.apache.fury.config.CompatibleMode;

import io.quarkus.runtime.annotations.ConfigDocMapKey;
import io.quarkus.runtime.annotations.ConfigDocSection;
import io.quarkus.runtime.annotations.ConfigPhase;
Expand All @@ -17,6 +19,40 @@ public interface FuryBuildTimeConfig {
@WithDefault("true")
boolean requiredClassRegistration();

/** Whether track shared or circular references. */
@WithDefault("false")
boolean trackRef();

/**
* Set class schema compatible mode.
* <br>
* SCHEMA_CONSISTENT: Class schema must be consistent between serialization peer and deserialization peer.
* <br>
* COMPATIBLE: Class schema can be different between serialization peer and deserialization peer. They can
* add/delete fields independently.
*/
@WithDefault("SCHEMA_CONSISTENT")
CompatibleMode compatibleMode();

/** Use variable length encoding for int/long. */
@WithDefault("true")
boolean compressNumber();

/** Whether compress string for small size. */
@WithDefault("true")
boolean compressString();

/**
* Whether deserialize/skip data of un-existed class. If not enabled, an exception will be thrown
* if class not exist.
*/
@WithDefault("false")
boolean deserializeNonexistentClass();

/** If an enum value doesn't exist, return a null instead of throws exception. */
@WithDefault("false")
boolean deserializeNonexistentEnumValueAsNull();

/** Whether to use thread safe fury. The default is true. */
@WithDefault("true")
boolean threadSafe();
Expand Down
8 changes: 7 additions & 1 deletion runtime/src/main/java/io/quarkiverse/fury/FuryRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ public RuntimeValue<BaseFury> createFury(
final FuryBuildTimeConfig config, final BeanContainer beanContainer) {
// create the Fury instance from the config
FuryBuilder builder = Fury.builder();
builder.requireClassRegistration(config.requiredClassRegistration());
builder.requireClassRegistration(config.requiredClassRegistration())
.withRefTracking(config.trackRef())
.withCompatibleMode(config.compatibleMode())
.withDeserializeNonexistentClass(config.deserializeNonexistentClass())
.deserializeNonexistentEnumValueAsNull(config.deserializeNonexistentEnumValueAsNull())
.withNumberCompressed(config.compressNumber())
.withStringCompressed(config.compressString());
BaseFury fury = config.threadSafe() ? builder.buildThreadSafeFury() : builder.build();

// register to the container
Expand Down

0 comments on commit 1f1e673

Please sign in to comment.