Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
wenxuwan committed Oct 26, 2021
2 parents bed7ffd + 3d3ffb6 commit 0b07491
Show file tree
Hide file tree
Showing 82 changed files with 30,515 additions and 16,606 deletions.
7 changes: 0 additions & 7 deletions components/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,13 @@ require (
github.com/go-redis/redis/v8 v8.8.0
github.com/go-zookeeper/zk v1.0.2
github.com/golang/mock v1.4.4
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/uuid v1.2.0
github.com/lyft/protoc-gen-validate v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/minio/minio-go/v6 v6.0.57
github.com/mitchellh/mapstructure v1.3.3 // indirect
github.com/mosn/binding v0.0.0-20200413092018-2b47bdb20a9f // indirect
github.com/mosn/easygo v0.0.0-20201210062404-62796fdb3827 // indirect
github.com/mosn/registry v0.0.0-20210108061200-d7b63bc1904b // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/spf13/afero v1.2.2 // indirect
github.com/stretchr/testify v1.7.0
github.com/tetratelabs/proxy-wasm-go-sdk v0.0.13 // indirect
github.com/valyala/fasthttp v1.26.0
github.com/yuin/gopher-lua v0.0.0-20200603152657-dc2b0ca8b37e // indirect
github.com/zouyx/agollo/v4 v4.0.7
Expand Down
91 changes: 0 additions & 91 deletions components/go.sum

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions components/pubsub/types.go
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"
)
103 changes: 103 additions & 0 deletions configs/config_redis.json
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"
}
]
}
]
}
]
}
12 changes: 3 additions & 9 deletions demo/pubsub/redis/client/publish_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,11 @@ func main() {
}

func testPublish(cli client.Client) error {
in := &client.PublishEventRequest{
PubsubName: "redis",
Topic: topicName,
Data: []byte("value1"),
DataContentType: "",
Metadata: nil,
}
err := cli.PublishEvent(context.Background(), in)
data := []byte("value1")
err := cli.PublishEvent(context.Background(), "redis",topicName, data)
if err != nil {
panic(err)
}
fmt.Printf("Published a new event.Topic: %s ,Data: %s \n", in.Topic, in.Data)
fmt.Printf("Published a new event.Topic: %s ,Data: %s \n", topicName, data)
return err
}
10 changes: 7 additions & 3 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
- [Sequencer](en/component_specs/sequencer/common.md)
- [Etcd](en/component_specs/sequencer/etcd.md)
- [Redis](en/component_specs/sequencer/redis.md)
- [Zookeeper](en/component_specs/sequencer/zookeeper.md)
- Design documents
- [Actuator design doc](en/design/actuator/actuator-design-doc.md)
- [Configuration API with Apollo](en/design/configuration/configuration-api-with-apollo.md)
Expand All @@ -61,8 +62,11 @@
- [Distributed lock API design](en/design/lock/lock-api-design.md)
- [FaaS design](en/design/faas/faas-poc-design.md)
- Contributing
- [Layotto contributor guide](en/development/CONTRIBUTING.md)
- [Document Contribution Guide](en/development/contributing-doc.md)
- [Component Development Guide](en/development/developing-component.md)
- [Development specification when adding API](en/development/developing-api.md)
- [How to generate API document](en/api_reference/how_to_generate_api_doc.md)
- You wanna modify proto files or API definition?
- [Development specification when adding API](en/development/developing-api.md)
- [How to generate API document based on the proto files](en/api_reference/how_to_generate_api_doc.md)
- [Explanation for github workflow](en/development/explanation-for-github-workflow.md)
- [Layotto contributor guide](en/development/CONTRIBUTING.md)

66 changes: 66 additions & 0 deletions docs/en/development/explanation-for-github-workflow.md
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
97 changes: 96 additions & 1 deletion docs/en/sdk_reference/java/start.md
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)
Loading

0 comments on commit 0b07491

Please sign in to comment.