-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main'
- Loading branch information
Showing
82 changed files
with
30,515 additions
and
16,606 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,21 @@ | ||
// 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 pubsub | ||
|
||
const ( | ||
// DefaultCloudEventType is the default event type for a runtime published event | ||
DefaultCloudEventType = "com.runtime.event.sent" | ||
// DefaultCloudEventSource is the default event source | ||
DefaultCloudEventSource = "runtime" | ||
) |
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,103 @@ | ||
{ | ||
"servers": [ | ||
{ | ||
"default_log_path": "stdout", | ||
"default_log_level": "DEBUG", | ||
"routers": [ | ||
{ | ||
"router_config_name": "actuator_dont_need_router" | ||
} | ||
], | ||
"listeners": [ | ||
{ | ||
"name": "grpc", | ||
"address": "127.0.0.1:34904", | ||
"bind_port": true, | ||
"filter_chains": [ | ||
{ | ||
"filters": [ | ||
{ | ||
"type": "tcpcopy", | ||
"config": { | ||
"strategy": { | ||
"switch": "ON", | ||
"interval": 30, | ||
"duration": 10, | ||
"cpu_max_rate": 80, | ||
"mem_max_rate": 80 | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "grpc", | ||
"config": { | ||
"server_name": "runtime", | ||
"grpc_config": { | ||
"hellos": { | ||
"helloworld": { | ||
"hello": "greeting" | ||
} | ||
}, | ||
"state": { | ||
"redis": { | ||
"metadata": { | ||
"redisHost": "localhost:6380", | ||
"redisPassword": "" | ||
} | ||
} | ||
}, | ||
"sequencer": { | ||
"redis": { | ||
"metadata": { | ||
"redisHost": "127.0.0.1:6380", | ||
"redisPassword": "" | ||
} | ||
} | ||
}, | ||
"lock": { | ||
"redis": { | ||
"metadata": { | ||
"redisHost": "localhost:6380", | ||
"redisPassword": "" | ||
} | ||
} | ||
}, | ||
"app": { | ||
"app_id": "app1", | ||
"grpc_callback_port": 9999 | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "actuator", | ||
"address": "127.0.0.1:34999", | ||
"bind_port": true, | ||
"filter_chains": [ | ||
{ | ||
"filters": [ | ||
{ | ||
"type": "proxy", | ||
"config": { | ||
"downstream_protocol": "Http1", | ||
"upstream_protocol": "Http1", | ||
"router_config_name": "actuator_dont_need_router" | ||
} | ||
} | ||
] | ||
} | ||
], | ||
"stream_filters": [ | ||
{ | ||
"type": "actuator_filter" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
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,66 @@ | ||
This document explain each component of Layotto's github workflow. | ||
|
||
Note: configuration files of Layotto github workflow are [here](https://github.com/mosn/layotto/tree/main/.github/workflows) | ||
|
||
## 1. Cron jobs | ||
### stale bot | ||
![img_1.png](../../img/development/workflow/img_1.png) | ||
|
||
We use [Close Stale Issues](https://github.com/marketplace/actions/close-stale-issues) . | ||
|
||
An issue or PR will be automatically marked as stale if it has not had recent activity in the last 30 days. It will be closed in the next 7 days unless it is tagged (pinned, security, good first issue or help wanted) or other activity occurs. | ||
|
||
**If a community task issue was closed by this bot,then the task can be assigned to others.** | ||
|
||
Merged in https://github.com/mosn/layotto/pull/246 | ||
|
||
## 2. CI/CD | ||
![img.png](../../img/development/workflow/img.png) | ||
### 2.1. Chore | ||
#### <1> cla bot | ||
|
||
check if the contributor has signed cla | ||
|
||
#### TODO: Automatically generate new API reference when proto files are modified | ||
|
||
Currently [we have to do it manually](https://mosn.io/layotto/#/en/api_reference/how_to_generate_api_doc) . | ||
|
||
The generated document is [here](https://github.com/mosn/layotto/blob/main/docs/en/api_reference/api_reference_v1.md) | ||
|
||
![img_2.png](../../img/development/workflow/img_2.png) | ||
|
||
### 2.2. Test | ||
#### <5> Run unit tests | ||
#### <5> Check if you have done `go fmt` | ||
#### <2><3> Make sure ut coverage ratio won't decrease | ||
|
||
See https://docs.codecov.com/docs/commit-status#branches | ||
|
||
#### TODO: Integration tests | ||
|
||
|
||
### 2.3. Lint | ||
#### <4> License checker | ||
We use https://github.com/marketplace/actions/license-eye | ||
|
||
Merged in https://github.com/mosn/layotto/pull/247 | ||
|
||
##### How to add license headers for all files automatically? | ||
In Layotto directory: | ||
|
||
```shell | ||
docker run -it --rm -v $(pwd):/github/workspace apache/skywalking-eyes header fix | ||
``` | ||
|
||
It will add license headers for code files recursively. | ||
|
||
See https://github.com/marketplace/actions/license-eye#docker-image for details | ||
|
||
#### TODO: PR title lint | ||
~~#### TODO: PR body lint?~~ | ||
#### TODO: Code style lint | ||
For example,find out `go xxx()` without `recover` | ||
We can use go lint and refer to MOSN's configuration | ||
|
||
#### ~~- Commit message lint~~ (reverted) | ||
see https://github.com/mosn/layotto/issues/243 |
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 |
---|---|---|
@@ -1 +1,96 @@ | ||
Under Construction | ||
## How to use java sdk | ||
|
||
### 1. import sdk | ||
|
||
For a Maven project, add the following to your `pom.xml` file: | ||
|
||
```xml | ||
|
||
<project> | ||
... | ||
<dependencies> | ||
... | ||
<dependency> | ||
<groupId>io.mosn.layotto</groupId> | ||
<artifactId>runtime-sdk-parent</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</dependency> | ||
... | ||
</dependencies> | ||
... | ||
</project> | ||
``` | ||
|
||
### 2. Run the examples | ||
|
||
Clone this repository including the submodules: | ||
|
||
```sh | ||
git clone https://github.com/mosn/layotto.git | ||
``` | ||
|
||
Build and run Layotto: | ||
|
||
```bash | ||
# 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](https://maven.apache.org/install.html) (Apache Maven version 3.x) project: | ||
|
||
```sh | ||
# 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: | ||
|
||
* Hello world: `${projectpath}/sdk/java-sdk/examples/src/main/java/io/mosn/layotto/examples/helloworld` | ||
* State management: `${projectpath}/sdk/java-sdk/examples/src/main/java/io/mosn/layotto/examples/state` | ||
* Pubsub API: `${projectpath}/sdk/java-sdk/examples/src/main/java/io/mosn/layotto/examples/pubsub` | ||
|
||
## How to generate a Java PROTO file | ||
|
||
### 1. Download proto compiler [protoc](https://github.com/protocolbuffers/protobuf/releases) | ||
|
||
my protoc version: | ||
|
||
```shell | ||
$ protoc --version | ||
libprotoc 3.11.2 | ||
``` | ||
|
||
### 2. Check `option` fields in these proto files | ||
|
||
Make sure these `option` fields have been configurated. | ||
|
||
spec/proto/runtime/v1/appcallback.proto : | ||
|
||
```protobuf | ||
option java_outer_classname = "AppCallbackProto"; | ||
option java_package = "spec.proto.runtime.v1"; | ||
``` | ||
|
||
spec/proto/runtime/v1/runtime.proto : | ||
|
||
```protobuf | ||
option java_outer_classname = "RuntimeProto"; | ||
option java_package = "spec.proto.runtime.v1"; | ||
``` | ||
|
||
### 3. Compile them into corresponding `JAVA` files | ||
|
||
```shell | ||
# make sure you replace this `${your PROJECT path}` with your own project path. | ||
cd ${your PROJECT path}/spec/proto/runtime/v1 | ||
protoc -I=. --java_out=./ runtime.proto | ||
``` | ||
|
||
PS: We recommend that you use the maven plugin `protoc-gen-grpc-java` to generate these protobuf and grpc related java code. | ||
|
||
If you are using [IntelliJ IDEA](https://www.jetbrains.com/help/idea/discover-intellij-idea.html) ,just double-click the maven plugin and the IDE will compile proto files automatically: | ||
|
||
![img.png](../../../img/sdk/img.png) |
Oops, something went wrong.