-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce handshake to client and gRPC server (#36)
Java implementation of numaproj/numaflow-go#42 Signed-off-by: Keran Yang <[email protected]>
- Loading branch information
Showing
19 changed files
with
325 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.numaproj.numaflow.info; | ||
|
||
import com.fasterxml.jackson.annotation.JsonValue; | ||
|
||
/** | ||
* Please exercise cautions when updating the values below because the exact same values are defined in other Numaflow SDKs | ||
* to form a contract between server and clients. | ||
*/ | ||
public enum Language { | ||
GO("go"), | ||
PYTHON("python"), | ||
JAVA("java"); | ||
|
||
private final String name; | ||
|
||
Language(String name) { | ||
this.name = name; | ||
} | ||
|
||
@JsonValue | ||
public String getName() { | ||
return name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.numaproj.numaflow.info; | ||
|
||
import com.fasterxml.jackson.annotation.JsonValue; | ||
|
||
/** | ||
* Please exercise cautions when updating the values below because the exact same values are defined in other Numaflow SDKs | ||
* to form a contract between server and clients. | ||
*/ | ||
public enum Protocol { | ||
UDS_PROTOCOL("uds"), | ||
TCP_PROTOCOL("tcp"); | ||
|
||
private final String name; | ||
|
||
Protocol(String name) { | ||
this.name = name; | ||
} | ||
|
||
@JsonValue | ||
public String getName() { | ||
return name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.numaproj.numaflow.info; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Server Information to be used by client to determine: | ||
* - protocol: what is right protocol to use (UDS or TCP) | ||
* - language: what is language used by the server | ||
* - version: what is the numaflow sdk version used by the server | ||
* - metadata: other information | ||
*/ | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class ServerInfo { | ||
@JsonProperty("protocol") | ||
private Protocol protocol; | ||
@JsonProperty("language") | ||
private Language language; | ||
@JsonProperty("version") | ||
private String version; | ||
@JsonProperty("metadata") | ||
private Map<String, String> metadata; | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/io/numaproj/numaflow/info/ServerInfoAccessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.numaproj.numaflow.info; | ||
|
||
public interface ServerInfoAccessor { | ||
/** | ||
* Get runtime Java SDK version. | ||
*/ | ||
String getSDKVersion(); | ||
|
||
/** | ||
* Delete filePath if it exists. | ||
* Write serverInfo to filePath in Json format. | ||
* Append {@link ServerInfoConstants#EOF} as a new line to indicate end of file. | ||
* | ||
* @param serverInfo server information POJO | ||
* @param filePath file path to write to | ||
* | ||
* @throws Exception any exceptions are thrown to the caller. | ||
*/ | ||
void write(ServerInfo serverInfo, String filePath) throws Exception; | ||
|
||
/** | ||
* Read from filePath to retrieve server information POJO. | ||
* This API is only used for unit tests. | ||
* | ||
* @param filePath file path to read from | ||
* | ||
* @return server information POJO | ||
* | ||
* @throws Exception any exceptions are thrown to the caller. | ||
*/ | ||
ServerInfo read(String filePath) throws Exception; | ||
} |
Oops, something went wrong.