Skip to content

Commit

Permalink
Merge pull request #352 from camunda-community-hub/np-allow-setting-d…
Browse files Browse the repository at this point in the history
…ebug-port

feat(engine): allow setting the exporter receiver port
  • Loading branch information
npepinpe authored Sep 23, 2022
2 parents 3a3546f + 68a2270 commit c00402a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ interface Builder {
*/
Builder withAutoAcknowledge(final boolean acknowledge);

/**
* Pre-assigns the port to use for the debug receive, i.e. the socket used to receive exported
* records from the container(s). By default, this is 0, i.e. a random port.
*
* @param port the port to assign to the receiver
* @return itself for chaining
*/
Builder withDebugReceiverPort(final int port);

/**
* Builds a {@link ContainerEngine} based on the configuration. If nothing else was called, will
* build an engine using a default {@link io.zeebe.containers.ZeebeContainer}, an idle period of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ final class ContainerEngineBuilder implements Builder {
private Duration idlePeriod;
private Duration gracePeriod;
private boolean autoAcknowledge;
private int debugReceiverPort;

@Override
public <T extends GenericContainer<T> & ZeebeGatewayNode<T> & ZeebeBrokerNode<T>>
Expand Down Expand Up @@ -99,15 +100,23 @@ public Builder withAutoAcknowledge(final boolean autoAcknowledge) {
return this;
}

@SuppressWarnings("unchecked")
@Override
public Builder withDebugReceiverPort(final int debugReceiverPort) {
this.debugReceiverPort = debugReceiverPort;
return this;
}

@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public ContainerEngine build() {
final Duration listGracePeriod = Optional.ofNullable(gracePeriod).orElse(DEFAULT_GRACE_PERIOD);
final Duration receiveIdlePeriod = Optional.ofNullable(idlePeriod).orElse(DEFAULT_IDLE_PERIOD);
final InfiniteList<Record<?>> records = new InfiniteList<>(listGracePeriod);
final DebugReceiverStream recordStream =
new DebugReceiverStream(
records, new DebugReceiver(records::add, autoAcknowledge), receiveIdlePeriod);
records,
new DebugReceiver(records::add, debugReceiverPort, autoAcknowledge),
receiveIdlePeriod);

try {
if (container != null) {
Expand Down

0 comments on commit c00402a

Please sign in to comment.