Skip to content
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 @@ -37,10 +37,11 @@ protected GrpcServiceContainerEnvironment buildContainerEnvironment(
@Override
protected List<GrpcPlatformServerDefinition> getServerDefinitions() {
return List.of(
new GrpcPlatformServerDefinition(
"networked-" + this.getServiceName(),
this.getServicePort(),
this.getServiceFactories()));
GrpcPlatformServerDefinition.builder()
.name("networked-" + this.getServiceName())
.port(this.getServicePort())
.serviceFactories(this.getServiceFactories())
.build());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
public class GrpcPlatformServerDefinition {
String name;
int port;
@Singular
Collection<GrpcPlatformServiceFactory> serviceFactories;
int maxInboundMessageSize;
@Singular Collection<GrpcPlatformServiceFactory> serviceFactories;
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ protected void doInit() {
this.grpcChannelRegistry = this.buildChannelRegistry();
Map<GrpcPlatformServerDefinition, ServerBuilder<?>> serverBuilderMap =
this.getServerDefinitions().stream()
.collect(
Collectors.toUnmodifiableMap(
Function.identity(),
definition -> ServerBuilder.forPort(definition.getPort())));
.collect(Collectors.toUnmodifiableMap(Function.identity(), this::initializeBuilder));
final ServerBuilder<?> inProcessServerBuilder =
InProcessServerBuilder.forName(this.getInProcessServerName())
.addService(this.healthStatusManager.getHealthService());
Expand Down Expand Up @@ -219,6 +216,16 @@ protected void registerManagedPeriodicTask(PlatformPeriodicTaskDefinition period
protected abstract GrpcServiceContainerEnvironment buildContainerEnvironment(
InProcessGrpcChannelRegistry channelRegistry, HealthStatusManager healthStatusManager);

private ServerBuilder<?> initializeBuilder(GrpcPlatformServerDefinition serverDefinition) {
ServerBuilder<?> builder = ServerBuilder.forPort(serverDefinition.getPort());

if (serverDefinition.getMaxInboundMessageSize() > 0) {
builder.maxInboundMessageSize(serverDefinition.getMaxInboundMessageSize());
}

return builder;
}

@Value
private static class ConstructedServer {
String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import io.grpc.protobuf.services.HealthStatusManager;
import java.util.List;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
import org.hypertrace.core.grpcutils.client.InProcessGrpcChannelRegistry;
import org.hypertrace.core.serviceframework.config.ConfigClient;
Expand Down Expand Up @@ -30,10 +29,11 @@ protected int getServicePort() {

protected List<GrpcPlatformServerDefinition> getServerDefinitions() {
return List.of(
new GrpcPlatformServerDefinition(
"networked-" + this.getServiceName(),
this.getServicePort(),
Set.of(this.getServiceFactory())));
GrpcPlatformServerDefinition.builder()
.name("networked-" + this.getServiceName())
.port(this.getServicePort())
.serviceFactory(this.getServiceFactory())
.build());
}

@Override
Expand Down