forked from layotto/java-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add uds support for java sdk (layotto#51)
Co-authored-by: 梓淞 <yuziyuan.yzy@antgroup.com>
- Loading branch information
1 parent
f7ef90c
commit 0d0be8e
Showing
10 changed files
with
335 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<artifactId>runtime-sdk-parent</artifactId> | ||
<groupId>io.mosn.layotto</groupId> | ||
<version>1.3.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<groupId>io.mosn.layotto</groupId> | ||
<artifactId>examples-uds</artifactId> | ||
<version>1.3.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<maven.compiler.source>8</maven.compiler.source> | ||
<maven.compiler.target>8</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.mosn.layotto</groupId> | ||
<artifactId>runtime-sdk</artifactId> | ||
<version>1.3.0-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-api</artifactId> | ||
<version>2.9.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-core</artifactId> | ||
<version>2.9.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-slf4j-impl</artifactId> | ||
<version>2.9.1</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<sourceDirectory>src/main/java</sourceDirectory> | ||
<finalName>examples-uds</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<version>3.2.0</version> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<mainClass>io.mosn.layotto.examples.uds.Demo</mainClass> | ||
</manifest> | ||
</archive> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>assemble-all</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
35 changes: 35 additions & 0 deletions
35
examples-uds/src/main/java/io/mosn/layotto/examples/uds/Demo.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,35 @@ | ||
/* | ||
* Copyright 2021 Layotto Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.mosn.layotto.examples.uds; | ||
|
||
import io.grpc.netty.shaded.io.netty.channel.unix.DomainSocketAddress; | ||
import io.mosn.layotto.v1.RuntimeClientBuilder; | ||
import spec.sdk.runtime.v1.client.RuntimeClient; | ||
|
||
public class Demo { | ||
|
||
public static void main(String[] args) { | ||
DomainSocketAddress udsAddress = new DomainSocketAddress("/tmp/client-proxy.sock"); | ||
RuntimeClient client = new RuntimeClientBuilder() | ||
.withUdsSocket(udsAddress) | ||
.build(); | ||
|
||
String resp = client.sayHello("helloworld"); | ||
if (!"greeting, helloworld".equals(resp)) { | ||
throw new RuntimeException("Unexpected result:" + resp); | ||
} | ||
System.out.println(resp); | ||
} | ||
} |
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,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Configuration status="WARN" monitorInterval="30"> | ||
<Properties> | ||
<Property name="LOG_PATTERN">%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1} - %m%n</Property> | ||
</Properties> | ||
|
||
<Appenders> | ||
<Console name="console" target="SYSTEM_OUT" follow="true"> | ||
<PatternLayout pattern="${LOG_PATTERN}"/> | ||
</Console> | ||
</Appenders> | ||
|
||
<Loggers> | ||
<Root level="info"> | ||
<AppenderRef ref="console"/> | ||
</Root> | ||
</Loggers> | ||
</Configuration> |
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
Oops, something went wrong.