Skip to content

Commit

Permalink
chore: write server info for sideinput sdk
Browse files Browse the repository at this point in the history
Signed-off-by: a3hadi <[email protected]>
  • Loading branch information
ayildirim21 committed Jan 24, 2024
1 parent cb91f37 commit 45858ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/io/numaproj/numaflow/sideinput/GRPCConfig.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.numaproj.numaflow.sideinput;

import io.numaproj.numaflow.info.ServerInfoAccessor;
import lombok.Builder;
import lombok.Getter;

Expand All @@ -11,12 +12,14 @@
public class GRPCConfig {
private String socketPath;
private int maxMessageSize;
private String infoFilePath;

/**
* Static method to create default GRPCConfig.
*/
static GRPCConfig defaultGrpcConfig() {
return GRPCConfig.newBuilder()
.infoFilePath(ServerInfoAccessor.DEFAULT_SERVER_INFO_FILE_PATH)
.maxMessageSize(Constants.DEFAULT_MESSAGE_SIZE)
.socketPath(Constants.DEFAULT_SOCKET_PATH).build();
}
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/io/numaproj/numaflow/sideinput/Server.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package io.numaproj.numaflow.sideinput;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.annotations.VisibleForTesting;
import io.grpc.ServerBuilder;
import io.numaproj.numaflow.shared.GrpcServerUtils;
import io.numaproj.numaflow.info.ServerInfoAccessor;
import io.numaproj.numaflow.info.ServerInfoAccessorImpl;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;
Expand All @@ -15,6 +18,7 @@ public class Server {

private final GRPCConfig grpcConfig;
private final Service service;
private final ServerInfoAccessor serverInfoAccessor = new ServerInfoAccessorImpl(new ObjectMapper());
private io.grpc.Server server;

/**
Expand Down Expand Up @@ -43,6 +47,10 @@ public Server(SideInputRetriever sideInputRetriever, GRPCConfig grpcConfig) {
* @throws Exception if server fails to start
*/
public void start() throws Exception {
GrpcServerUtils.writeServerInfo(
serverInfoAccessor,
grpcConfig.getSocketPath(),
grpcConfig.getInfoFilePath());

if (this.server == null) {
// create server builder
Expand Down

0 comments on commit 45858ae

Please sign in to comment.