Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/apache/incubator-eventmesh
Browse files Browse the repository at this point in the history
… into develop
  • Loading branch information
xwm1992 committed Dec 14, 2021
2 parents 49be49d + 9393d72 commit 419516b
Show file tree
Hide file tree
Showing 33 changed files with 148 additions and 278 deletions.
23 changes: 1 addition & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,17 @@ on:
jobs:
build:
name: Build

runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest]
language:
- 'java'
java: [8, 11]
runs-on: ${{ matrix.os }}

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
languages: ${{ matrix.language }}

- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v1
with:
Expand All @@ -70,15 +57,8 @@ jobs:
- name: Install plugin
run: ./gradlew installPlugin

- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@v1

- name: Upload coverage report to codecov.io
run: bash <(curl -s https://codecov.io/bash) || echo 'Failed to upload coverage report!'

checkstyle:
name: Checkstyle

runs-on: ubuntu-latest

steps:
Expand All @@ -100,7 +80,6 @@ jobs:
license-header-check:
name: License header Check

runs-on: ubuntu-latest

steps:
Expand Down
31 changes: 20 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ Here are the workflow for contributors:

1. Fork to your own
2. Clone fork to local repository
```shell
```git
git clone [email protected]:yourgithub/incubator-eventmesh.git
```
3. Create a new branch and work on it
```shell
```git
git checkout -b fix_patch_xx
```
4. Keep your branch in sync
```shell
```git
git remote add upstream [email protected]:apache/incubator-eventmesh.git
git fetch upstream develop:upstream_develop
git rebase upstream_develop
Expand All @@ -65,18 +65,20 @@ EventMesh repository, and the related Issue will be closed.
We use [GitHub Issues](https://github.com/apache/incubator-eventmesh/issues)
and [Pull Requests](https://github.com/apache/incubator-eventmesh/pulls) for trackers.

If you find a typo in a document, find a bug in code, or want new features, or want to give suggestions, you
If you find a bug in code, or want new features, or want to give suggestions, you
can [open an issue on GitHub](https://github.com/apache/incubator-eventmesh/issues/new) to report it. Please follow the
guideline message in the issue template.

If you want to contribute, please follow the [contribution workflow](#github-workflow) and create a new pull request. If
your PR contains large changes, e.g. component refactor or new components, please write detailed documents about its
If you want to contribute, please follow the [contribution workflow](#github-workflow) and create a new pull request. Your PR title should start with [ISSUE #xx].
If your PR contains large changes, e.g. component refactor or new components, please write detailed documents about its
design and usage.

Note that a single pull request should not be too large. If heavy changes are required, it's better to separate the
If your change is about a typo or small optimize, you needn't create an Issue, just submit a PR and title with [MINOR].

[Note]: A single pull request should not be too large. If heavy changes are required, it's better to separate the
changes to a few individual PRs.

### Code review
### PR review

All code should be well reviewed by one or more committers. Some principles:

Expand All @@ -88,11 +90,18 @@ All code should be well reviewed by one or more committers. Some principles:

EventMesh follows [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) policy. All source files should
have the Apache License header added to the file header. EventMesh uses the [apache/skywalking-eyes](https://github.com/apache/skywalking-eyes) to check
the source file header, and EventMesh uses [Gradle-License-Report](https://github.com/jk1/Gradle-License-Report) plugin to check for third-part dependencies.
When you need to add a three-part dependency, you need to register the newly added dependency in tool/license/allowed-licenses.txt, you can execute `./gradlew clean checkLicense` to judge
whether there exist dependencies have been added, and the newly added three-part libraries need to meet [ASF 3RD PARTY LICENSE POLICY](https://apache.org/legal/resolved.html).
the source file header.

EventMesh uses [check-LICENSE.sh](tools/third-party-dependencies/check-LICENSE.sh) script to check for third-part dependencies.
When you need to add a three-part dependency, you need to register the newly added dependency in tool/license/known-dependencies.txt. The newly added three-part libraries need to meet [ASF 3RD PARTY LICENSE POLICY](https://apache.org/legal/resolved.html).
It is highly recommended communicating with EventMesh community before you need to add a three-part library.

### PR merge

After a PR is approved by at least one committer, it can be merged. Before the merge, the committer can make changes to the commits message, requiring the commits
message to be clear without duplication, and use Squash and Merge to make sure one PR should only contain one commits.
For large multi-person PR, use Merge to merge, and fix the commits by rebase before merging.

## Community

### Contact us
Expand Down
35 changes: 22 additions & 13 deletions CONTRIBUTING.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ Editor -> Code Style -> Java -> Scheme -> Import Scheme -> CheckStyle Configurat

1. Fork到您个人仓库
2. 克隆到本地存储库
```shell
```git
git clone [email protected]:yourgithub/incubator-eventmesh.git
```
3. 创建一个新分支并对其进行处理
```shell
```git
git checkout -b fix_patch_xx
```
4. 保持分支与主库同步
```shell
```git
git remote add upstream [email protected]:apache/incubator-eventmesh.git
git fetch upstream develop:upstream_develop
git rebase upstream_develop
Expand All @@ -56,19 +56,20 @@ git rebase upstream_develop
### 打开问题/ PR

我们将使用Issues和Pull Requests作为跟踪器
[GitHub Issues](https://github.com/apache/incubator-eventmesh/issues)
[Pull Requests](https://github.com/apache/incubator-eventmesh/pulls)
- [GitHub Issues](https://github.com/apache/incubator-eventmesh/issues)
- [Pull Requests](https://github.com/apache/incubator-eventmesh/pulls)

如果您在文档中发现拼写错误,在代码中发现错误,想要新功能或提出建议, 您可以提出问题[在GitHub上打开问题](https://github.com/apache/incubator-eventmesh/issues/new)
请按照问题模板中的准则消息进行操作
如果您发现新的Bug,想要新功能或提出新当建议,您可以在GitHub上[创建Issue](https://github.com/apache/incubator-eventmesh/issues/new) ,请按照Issue模板中的准则进行操作。
如果您在文档中发现拼写错误,或者发现代码中存在可以进行微小的优化的地方,您可以无需创建Issue, 直接提交一个PR

如果您想贡献,请遵循[贡献工作流程](#github-workflow)并创建一个新的拉取请求。 如果您的PR包含较大的更改,例如组件重构或新组件,请写详细文档 有关其设计和使用的信息。
对于PR的标题请依照[ISSUE #xx]进行开头,如果是细小的改动请以[MINOR]进行开头。

请注意,单个拉取请求不应太大。如果需要进行重大更改,最好将更改分开 到一些个人PR。
【注意】: 单个PR不应太大。如果需要进行重大更改,最好将更改分开 到一些个人PR。

### 代码审查
### PR审查

所有代码应由一个或多个committer进行良好的审查。一些原则:
所有PR应由一个或多个committer进行良好的审查。一些原则:

- 可读性: 重要代码应有详细记录。符合我们的[代码风格](./style/checkStyle.xml)
- 优雅: 新功能,类或组件应经过精心设计
Expand All @@ -78,10 +79,18 @@ git rebase upstream_develop

EventMesh遵循[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) 政策。
所有的源代码文件应该在文件头部添加Apache License header,EventMesh会使用[apache/skywalking-eyes](https://github.com/apache/skywalking-eyes)
对源代码文件头进行校验。EventMesh使用[Gradle-License-Report](https://github.com/jk1/Gradle-License-Report)插件
检查第三方依赖,当你需要添加三方依赖时,你需要将新添加的依赖注册在tool/license/allowed-licenses.txt中,你可以通过执行`./gradlew clean checkLicense`命令可以判断当前是否有license尚未添加,
对源代码文件头进行校验。

EventMesh使用[check-LICENSE.sh](tools/third-party-dependencies/check-LICENSE.sh)脚本
检查第三方依赖,当你需要添加三方依赖时,你需要将新添加的依赖注册在tool/license/known-dependencies.txt中,
同时新添加的三方库需要满足[Apache对于第三方的政策](https://apache.org/legal/resolved.html)
非常建议在需要添加三方依赖之前与EventMesh社区进行沟通。

当添加依赖时遇到问题时,社区PPMC会协助解决,非常建议在需要添加三方依赖之前与EventMesh社区进行沟通。

### PR合并

PR经过至少一个committer approve之后会由committer负责合并,在合并的时候,committer可以对commits信息进行修改,要求commits信息简洁明了,不重复。
在合并时使用Squash and merge, 要求一个PR保留一个commits。对于大型多人协助的PR,使用Merge进行合并,在合并之前通过rebase修正commits。

## 社区

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@
*/

dependencies {
implementation project(":eventmesh-spi")
api project(":eventmesh-spi")
implementation project(":eventmesh-common")
api 'io.cloudevents:cloudevents-core'
// api 'io.openmessaging:openmessaging-api'
api 'io.dropwizard.metrics:metrics-core'
api "io.dropwizard.metrics:metrics-healthchecks"
api "io.dropwizard.metrics:metrics-annotation"
api "io.dropwizard.metrics:metrics-json"

compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'

testCompileOnly 'org.projectlombok:lombok:1.18.22'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@

package org.apache.eventmesh.api.exception;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OnExceptionContext {

private String messageId;
Expand All @@ -27,30 +36,4 @@ public class OnExceptionContext {
* Detailed exception stack information.
*/
private ConnectorRuntimeException exception;


public String getMessageId() {
return messageId;
}

public void setMessageId(String messageId) {
this.messageId = messageId;
}

public String getTopic() {
return topic;
}

public void setTopic(String topic) {
this.topic = topic;
}


public ConnectorRuntimeException getException() {
return exception;
}

public void setException(ConnectorRuntimeException exception) {
this.exception = exception;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ List rocketmq = [
]

dependencies {
compileOnly project(":eventmesh-common")
compileOnly project(":eventmesh-connector-plugin:eventmesh-connector-api")
implementation project(":eventmesh-common")
implementation project(":eventmesh-connector-plugin:eventmesh-connector-api")
implementation rocketmq

testImplementation project(":eventmesh-connector-plugin:eventmesh-connector-api")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void put(MessageEntity messageEntity) throws InterruptedException {
* Get the first message at this queue, waiting for the message is available if the queue is empty,
* this method will not remove the message
*
* @return
* @return MessageEntity
* @throws InterruptedException
*/
public MessageEntity take() throws InterruptedException {
Expand All @@ -100,7 +100,7 @@ public MessageEntity take() throws InterruptedException {
/**
* Get the first message at this queue, if the queue is empty return null immediately
*
* @return
* @return MessageEntity
*/
public MessageEntity peek() {
ReentrantLock lock = this.lock;
Expand All @@ -115,7 +115,7 @@ public MessageEntity peek() {
/**
* Get the head in this queue
*
* @return
* @return MessageEntity
*/
public MessageEntity getHead() {
return peek();
Expand All @@ -124,7 +124,7 @@ public MessageEntity getHead() {
/**
* Get the tail in this queue
*
* @return
* @return MessageEntity
*/
public MessageEntity getTail() {
ReentrantLock lock = this.lock;
Expand All @@ -148,7 +148,7 @@ public MessageEntity getTail() {
* and calculate the index of this offset
*
* @param offset
* @return
* @return MessageEntity
*/
public MessageEntity getByOffset(long offset) {
ReentrantLock lock = this.lock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public CloudEvent getMessage(String topicName) {
*
* @param topicName topic name
* @param offset offset
* @return
* @return CloudEvent
*/
public CloudEvent getMessage(String topicName, long offset) {
TopicMetadata topicMetadata = new TopicMetadata(topicName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.eventmesh.api.SendResult;
import org.apache.eventmesh.api.exception.ConnectorRuntimeException;
import org.apache.eventmesh.api.exception.OnExceptionContext;
import org.apache.eventmesh.api.producer.Producer;
import org.apache.eventmesh.connector.standalone.broker.StandaloneBroker;
import org.apache.eventmesh.connector.standalone.broker.model.MessageEntity;

Expand Down Expand Up @@ -92,10 +91,11 @@ public void publish(CloudEvent cloudEvent, SendCallback sendCallback) throws Exc
SendResult sendResult = publish(cloudEvent);
sendCallback.onSuccess(sendResult);
} catch (Exception ex) {
OnExceptionContext onExceptionContext = new OnExceptionContext();
onExceptionContext.setMessageId(cloudEvent.getId());
onExceptionContext.setTopic(cloudEvent.getSubject());
onExceptionContext.setException(new ConnectorRuntimeException(ex));
OnExceptionContext onExceptionContext = OnExceptionContext.builder()
.messageId(cloudEvent.getId())
.topic(cloudEvent.getSubject())
.exception(new ConnectorRuntimeException(ex))
.build();
sendCallback.onException(onExceptionContext);
}
}
Expand All @@ -105,26 +105,22 @@ public void sendOneway(CloudEvent cloudEvent) {
}

public void sendAsync(CloudEvent cloudEvent, SendCallback sendCallback) {
Preconditions.checkNotNull(cloudEvent);
Preconditions.checkNotNull(sendCallback);
Preconditions.checkNotNull(cloudEvent, "CloudEvent cannot be null");
Preconditions.checkNotNull(sendCallback, "Callback cannot be null");
// todo: current is not async
try {
SendResult sendResult = publish(cloudEvent);
sendCallback.onSuccess(sendResult);
} catch (Exception ex) {
OnExceptionContext onExceptionContext = new OnExceptionContext();
onExceptionContext.setMessageId(cloudEvent.getId());
onExceptionContext.setTopic(cloudEvent.getSubject());
onExceptionContext.setException(new ConnectorRuntimeException(ex));
OnExceptionContext onExceptionContext = OnExceptionContext.builder()
.messageId(cloudEvent.getId())
.topic(cloudEvent.getSubject())
.exception(new ConnectorRuntimeException(ex))
.build();
sendCallback.onException(onExceptionContext);
}
}

// @Override
// public void request(CloudEvent cloudEvent, RequestReplyCallback rrCallback, long timeout) throws Exception {
// throw new ConnectorRuntimeException("Request is not supported");
// }

public void request(CloudEvent cloudEvent, RequestReplyCallback rrCallback, long timeout) throws Exception {
throw new ConnectorRuntimeException("Request is not supported");
}
Expand Down
Loading

0 comments on commit 419516b

Please sign in to comment.