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 clone() method to codec builders #174

Merged
merged 1 commit into from
Feb 2, 2021
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 @@ -32,6 +32,15 @@ public QuicClientCodecBuilder() {
super(false);
}

private QuicClientCodecBuilder(QuicCodecBuilder<QuicClientCodecBuilder> builder) {
super(builder);
}

@Override
public QuicClientCodecBuilder clone() {
return new QuicClientCodecBuilder(this);
}

@Override
protected ChannelHandler build(QuicheConfig config,
Function<QuicChannel, ? extends QuicSslEngine> sslEngineProvider,
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/io/netty/incubator/codec/quic/QuicCodecBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,35 @@ public abstract class QuicCodecBuilder<B extends QuicCodecBuilder<B>> {
private QuicCongestionControlAlgorithm congestionControlAlgorithm;
private int localConnIdLength = Quiche.QUICHE_MAX_CONN_ID_LEN;
private Function<QuicChannel, ? extends QuicSslEngine> sslEngineProvider;

QuicCodecBuilder(boolean server) {
Quic.ensureAvailability();
this.server = server;
}

QuicCodecBuilder(QuicCodecBuilder<B> builder) {
Quic.ensureAvailability();
this.server = builder.server;
this.grease = builder.grease;
this.earlyData = builder.earlyData;
this.maxIdleTimeout = builder.maxIdleTimeout;
this.maxRecvUdpPayloadSize = builder.maxRecvUdpPayloadSize;
this.maxSendUdpPayloadSize = builder.maxSendUdpPayloadSize;
this.initialMaxData = builder.initialMaxData;
this.initialMaxStreamDataBidiLocal = builder.initialMaxStreamDataBidiLocal;
this.initialMaxStreamDataBidiRemote = builder.initialMaxStreamDataBidiRemote;
this.initialMaxStreamDataUni = builder.initialMaxStreamDataUni;
this.initialMaxStreamsBidi = builder.initialMaxStreamsBidi;
this.initialMaxStreamsUni = builder.initialMaxStreamsUni;
this.ackDelayExponent = builder.ackDelayExponent;
this.maxAckDelay = builder.maxAckDelay;
this.disableActiveMigration = builder.disableActiveMigration;
this.enableHystart = builder.enableHystart;
this.congestionControlAlgorithm = builder.congestionControlAlgorithm;
this.localConnIdLength = builder.localConnIdLength;
this.sslEngineProvider = builder.sslEngineProvider;
}

/**
* Returns itself.
*
Expand Down Expand Up @@ -390,6 +414,13 @@ public final ChannelHandler build() {
}
}

/**
* Clone the builder
*
* @return the new instance that is a clone if this instance.
*/
public abstract B clone();

/**
* Builds the QUIC codec.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ public QuicServerCodecBuilder() {
super(true);
}

private QuicServerCodecBuilder(QuicServerCodecBuilder builder) {
super(builder);
options.putAll(builder.options);
attrs.putAll(builder.attrs);
streamOptions.putAll(builder.streamOptions);
streamAttrs.putAll(builder.streamAttrs);
handler = builder.handler;
streamHandler = builder.streamHandler;
connectionIdAddressGenerator = builder.connectionIdAddressGenerator;
tokenHandler = builder.tokenHandler;
}

@Override
public QuicServerCodecBuilder clone() {
return new QuicServerCodecBuilder(this);
}

/**
* Allow to specify a {@link ChannelOption} which is used for the {@link QuicChannel} instances once they got
* created. Use a value of {@code null} to remove a previous set {@link ChannelOption}.
Expand Down