Skip to content

Commit

Permalink
Remove weather lookup example (#4772)
Browse files Browse the repository at this point in the history
Ref #4769
  • Loading branch information
tiziano88 authored Feb 8, 2024
1 parent 1ec4fef commit 1bbcbc3
Show file tree
Hide file tree
Showing 26 changed files with 24 additions and 1,366 deletions.
127 changes: 1 addition & 126 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ members = [
"oak_functions/examples/echo/module",
"oak_functions/examples/invalid_module/module",
"oak_functions/examples/key_value_lookup/module",
"oak_functions/examples/weather_lookup/module",
"oak_functions/load_test",
"oak_functions/location_utils",
"oak_functions/lookup_data_checker",
"oak_functions/lookup_data_generator",
"oak_functions_abi",
"oak_functions_client",
Expand Down Expand Up @@ -91,7 +87,6 @@ codegen-units = 1
# Declare workspace-wide dependencies so that they don't need to use relative paths to refer to each other, and they are always kept in sync.
# Local crates.
benchmark = { path = "./oak_functions/examples/benchmark/module" }
location_utils = { path = "./oak_functions/location_utils" }
micro_rpc = { path = "./micro_rpc" }
micro_rpc_build = { path = "./micro_rpc_build" }
oak_attestation = { path = "./oak_attestation" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ package(
)

java_binary(
name = "weather_lookup_client",
name = "oak_functions_client",
srcs = ["Main.java"],
main_class = "com.google.oak.client.weather_lookup_client.Main",
main_class = "com.google.oak.client.oak_functions_client.Main",
deps = [
"//java/src/main/java/com/google/oak/client",
"//java/src/main/java/com/google/oak/remote_attestation:insecure_attestation_verifier",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
//

package com.google.oak.client.weather_lookup_client;
package com.google.oak.client.oak_functions_client;

import static java.nio.charset.StandardCharsets.UTF_8;

Expand All @@ -30,14 +30,13 @@
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.time.Clock;
import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Main {
private static Logger logger = Logger.getLogger(Main.class.getName());
private static final String EMPTY_API_KEY = "";
private static final String EXPECTED_RESPONSE_PATTERN =
"\\{\"temperature_degrees_celsius\":.*\\}";

public static void main(String[] args) throws Exception {
// Create a gRPC channel.
Expand All @@ -56,21 +55,20 @@ public static void main(String[] args) throws Exception {
OakClient.create(transport, new InsecureAttestationVerifier(), Clock.systemUTC());
OakClient<GrpcStreamingTransport> oakClient = oakClientCreateResult.unwrap("creating client");

// Test request coordinates are defined in `oak_functions/lookup_data_generator/src/data.rs`.
byte[] requestBody = "{\"lat\":0,\"lng\":0}".getBytes(UTF_8);
byte[] requestBody = "test data".getBytes(UTF_8);
Result<byte[], Exception> oakClientInvokeResult = oakClient.invoke(requestBody);
byte[] responseWrapperBytes = oakClientInvokeResult.unwrap("invoking client");
ResponseWrapper responseWrapper = ResponseWrapper.parseFrom(responseWrapperBytes);
logger.log(Level.INFO, "Client received response wrapper: " + responseWrapper.toString());
String decodedResponse =
new String(responseWrapper.getBody().toByteArray(), StandardCharsets.UTF_8);
byte[] responseBody = responseWrapper.getBody().toByteArray();

if (decodedResponse.matches(EXPECTED_RESPONSE_PATTERN)) {
logger.log(Level.INFO, "Client received the expected response: " + decodedResponse);
if (Arrays.equals(responseBody, requestBody)) {
logger.log(
Level.INFO, "Client received the expected response: " + Arrays.toString(responseBody));
} else {
logger.log(Level.INFO,
String.format(
"Expected pattern %s, received %s.", EXPECTED_RESPONSE_PATTERN, decodedResponse));
String.format("Expected response %s, received %s.", Arrays.toString(requestBody),
Arrays.toString(responseBody)));
System.exit(1);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Java Oak Functions Client

This in the Java version of the Oak Functions Client.

Build and run the client with the following command:

```bash
bazel run //java/src/main/java/com/google/oak/client/oak_functions_client -- http://localhost:8080
```

This file was deleted.

Loading

0 comments on commit 1bbcbc3

Please sign in to comment.