/java-sdk

java sdk for layotto

Primary LanguageJava

中文

How to use java sdk

1. import sdk

For a Maven project, add the following to your pom.xml file:

    <dependency>
        <groupId>io.mosn.layotto</groupId>
        <artifactId>runtime-sdk-parent</artifactId>
        <version>1.0.0</version>
    </dependency>

2. Run the examples

Clone this repository including the submodules:

git clone https://github.com/mosn/layotto.git

Build and run Layotto:

# make sure you replace this` ${projectpath}` with your own project path.
cd ${projectpath}/cmd/layotto
go build
./layotto start -c ../../configs/config_redis.json

Then head over to build the java-sdk Maven (Apache Maven version 3.x) project:

# make sure you replace this` ${projectpath}` with your own project path.
cd ${projectpath}/sdk/java-sdk
mvn clean install

Try the following examples to learn more about this SDK:

java sdk developer guide

How to format java sdk code

Compile before submit your pull request:

mvn clean compile

It will format your code automatically.

How to generate a Java PROTO file

Solution A

make proto

The script will download the layotto proto files and compile them automatically.

Solution B

1. Copy the proto files to spec/src/main/spec
2. Check option fields in these proto files

Make sure these option fields have been configurated.

spec/proto/runtime/v1/appcallback.proto :

option java_outer_classname = "AppCallbackProto";
option java_package = "spec.proto.runtime.v1";

spec/proto/runtime/v1/runtime.proto :

option java_outer_classname = "RuntimeProto";
option java_package = "spec.proto.runtime.v1";
3. Compile them into corresponding JAVA files
# make sure you replace this `${your PROJECT path}` with your own project path.
cd ${your PROJECT path}
mvn compile