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

add fury builder options #20

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CompatibleMode is enum? I'm not very sure that it is supported here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it's an enum


/** 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
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