Skip to content

Commit

Permalink
Merge pull request #723 from jinrongluo/grpc
Browse files Browse the repository at this point in the history
[Issue #718] update Grpc Message Model name to SimpleMessage
  • Loading branch information
vongosling authored Feb 10, 2022
2 parents d6f9c3e + 48ab8d3 commit 7332d24
Show file tree
Hide file tree
Showing 130 changed files with 5,514 additions and 2,506 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ subprojects {
Set<String> rootProject = ["eventmesh-admin",
"eventmesh-common",
"eventmesh-connector-api",
"eventmesh-metrics-api",
"eventmesh-registry-api",
"eventmesh-runtime",
"eventmesh-security-api",
Expand Down
8 changes: 4 additions & 4 deletions docs/cn/instructions/eventmesh-runtime-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ message RequestHeader {
string protocolDesc = 12;
}
message EventMeshMessage {
message SimpleMessage {
RequestHeader header = 1;
string producerGroup = 2;
string topic = 3;
Expand Down Expand Up @@ -388,10 +388,10 @@ message Heartbeat {
```
service PublisherService {
# 异步事件生产
rpc publish(EventMeshMessage) returns (Response);
rpc publish(SimpleMessage) returns (Response);
# 同步事件生产
rpc requestReply(EventMeshMessage) returns (Response);
rpc requestReply(SimpleMessage) returns (Response);
# 批量事件生产
rpc batchPublish(BatchMessage) returns (Response);
Expand All @@ -406,7 +406,7 @@ service ConsumerService {
rpc subscribe(Subscription) returns (Response);
# 所消费事件通过 TCP stream推送事件
rpc subscribeStream(Subscription) returns (stream EventMeshMessage);
rpc subscribeStream(Subscription) returns (stream SimpleMessage);
rpc unsubscribe(Subscription) returns (Response);
}
Expand Down
4 changes: 2 additions & 2 deletions docs/cn/instructions/eventmesh-sdk-java-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ TCP, HTTP 和 GRPC 示例都在**eventmesh-example**模块下

### 3. GRPC 演示

> 对于 GRPC, eventmesh-sdk-java 实现了 Google gRPC 和 Google Protocol Buffers 协议. 它能异步和同步发送事件到 eventmesh-runtime.
> 它可以通过webhook和事件流方式订阅消费事件, 同时也支持Apache CloudEvents 协议.
> eventmesh-sdk-java 实现了 gRPC 协议. 它能异步和同步发送事件到 eventmesh-runtime.
> 它可以通过webhook和事件流方式订阅消费事件, 同时也支持 CNCF CloudEvents 协议.
<h4> 异步事件发送 和 webhook订阅 </h4>

Expand Down
8 changes: 6 additions & 2 deletions docs/cn/instructions/eventmesh-trace-Zipkin-instruction.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@

eventmesh-runtime/conf/eventmesh.properties中:

默认的exporter是log,需要手动改成Zipkin

```properties
#trace exporter
eventmesh.trace.exporter.type=Zipkin

```
下面是关于Zipkin的各种配置
```properties
#set the maximum batch size to use
eventmesh.trace.exporter.max.export.size=512
#set the queue size. This must be >= the export batch size
Expand All @@ -36,7 +40,7 @@ eventmesh.trace.export.zipkin.ip=localhost
eventmesh.trace.export.zipkin.port=9411
```

以上都是相关的配置,如果你十分熟悉zipkin的话可以自行修改
以上都是相关的配置,如果你十分熟悉Zipkin的话可以自行修改



Expand Down
287 changes: 287 additions & 0 deletions docs/en/features/eventmesh-workflow-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,287 @@
# EventMesh Workflow

## Business Problem

Imaging you are building a simple Order Management System for an E-Commerce Store.
The system should be able to receive and provision new orders from a store website. The provisioning process
should be able to process all orders, handle payments, as well as process shipments.

For high availability and high performance, you architect the system using event-driven architecture (EDA), and build microservice apps to handle
store frontend, order management, payment processing, and shipment management.
You deploy the whole system in a cloud environment. To handle high workloads, you leverage a messaging system to buffer the loads,
and scale up multiple instances of microservices. The architecture could look similar to:

![eventmesh-workflow-uc](../../images/features/eventmesh-workflow-usecase.jpg?raw=true)

While each microservice is acting on its own event channels, EventMesh plays a crucial role of doing Event Orchestration.

We use [CNCF Serverless Workflow](https://serverlessworkflow.io/) to describe this Event Workflow Orchestration.

## About CNCF Serverless Workflow

CNCF Serverless Workflow defines a vendor-neutral, open-source, and fully community-driven ecosystem
for defining and running DSL-based workflows that target the Serverless technology domain.

Serverless Workflow defines a Domain Specific Language (DSL)
to describe stateful and stateless workflow-based orchestrations of serverless functions and microservices.

More about this can be found in its [official github site](https://github.com/serverlessworkflow/specification)

## EventMesh Workflow

We leverage Serverless Workflow DSL to describe the EventMesh workflow. Based on its spec, the workflow is consists of a series of
workflow states used to describe the control-flow logic.
At this time we only support event related workflow states. See the supported states in [Workflow DSL Design](#workflow-dsl-design-wip).

A `workflow state` can include applicable `actions`, or services/functions that should be invoked during workflow execution.
These `actions` can reference reusable `function` definitions which define how these functions/services should be invoked.
They can also reference events that trigger event-based service invocations, and events to wait for that denote completion of
such event-based service invocation completion.

In EDA solution, we usually defined our event-driven microservice using AsyncAPI.
Serverless workflow `function` definitions support defining invocation semantics using AsyncAPI.
See [Using Funtions for AsyncAPI Service](https://github.com/serverlessworkflow/specification/blob/main/specification.md#using-functions-for-async-api-service-invocations)
for more information.

### AsyncAPI

AsyncAPI is an open source initiative that seeks to improve the current state of Event-Driven Architectures (EDA).
Our long-term goal is to make working with EDAs as easy as it is to work with REST APIs.
That goes from documentation to code generation, discovery to event management.
Most of the processes you apply to your REST APIs nowadays would be applicable to your event-driven/asynchronous APIs too.

See AsyncAPI detail in the [official site](https://www.asyncapi.com/docs/getting-started)

### Workflow Example

In this example, we build the event-driven workflow of the Order management system above.

First, we need to define AsyncAPI definitions for our microservice apps.

- Online Store App

```yaml
asyncapi: 2.2.0
info:
title: Online Store application
version: '0.1.0'
channels:
store/order:
subscribe:
operationId: newStoreOrder
message:
$ref : '#/components/NewOrder'

```

- Order Service

```yaml
asyncapi: 2.2.0
info:
title: Order Service
version: '0.1.0'
channels:
order/inbound:
publish:
operationId: sendOrder
message:
$ref : '#/components/Order'
order/outbound:
subscribe:
operationId: processedOrder
message:
$ref : '#/components/Order'
```
- Payment Service
```yaml
asyncapi: 2.2.0
info:
title: Payment Service
version: '0.1.0'
channels:
payment/inbound:
publish:
operationId: sendPayment
message:
$ref : '#/components/OrderPayment'
payment/outbound:
subscribe:
operationId: paymentReceipt
message:
$ref : '#/components/OrderPayment'
```
- Shipment Service
```yaml
asyncapi: 2.2.0
info:
title: Shipment Service
version: '0.1.0'
channels:
shipment/inbound:
publish:
operationId: sendShipment
message:
$ref : '#/components/OrderShipment'
```
Once that is defined, we define the order workflow that describes our Order Management business logic.
```yaml
id: storeorderworkflow
version: '1.0'
specVersion: '0.8'
name: Store Order Management Workflow
states:
- name: Receive New Order Event
type: event
onEvents:
- eventRefs:
- NewOrderEvent
actions:
- eventRef:
triggerEventRef: OrderServiceSendEvent
resultEventRef: OrderServiceResultEvent
- eventRef:
triggerEventRef: PaymentServiceSendEvent
resultEventRef: PaymentServiceResultEvent
transition: Check Payment Status
- name: Check Payment Status
type: switch
dataConditions:
- name: Payment Successfull
condition: "${ .payment.status == 'success' }"
transition: Send Order Shipment
- name: Payment Denied
condition: "${ .payment.status == 'denied' }"
end: true
defaultCondition:
end: true
- name: Send Order Shipment
type: operation
actions:
- eventRef:
triggerEventRef: ShipmentServiceSendEvent
end: true
events:
- name: NewOrderEvent
source: file://onlineStoreApp.yaml#newStoreOrder
type: asyncapi
kind: consumed
- name: OrderServiceSendEvent
source: file://orderService.yaml#sendOrder
type: asyncapi
kind: produced
- name: OrderServiceResultEvent
source: file://orderService.yaml#processedOrder
type: asyncapi
kind: consumed
- name: PaymentServiceSendEvent
source: file://paymentService.yaml#sendPayment
type: asyncapi
kind: produced
- name: PaymentServiceResultEvent
source: file://paymentService.yaml#paymentReceipt
type: asyncapi
kind: consumed
- name: ShipmentServiceSendEvent
source: file://shipmentService.yaml#sendShipment
type: asyncapi
kind: produced
```
The corresponding workflow diagram is the following:
![eventmesh-workflow-diag](../../images/features/eventmesh-workflow-diag.png?raw=true)
## EventMesh Workflow Engine
In the following architecture diagram, the EventMesh Catalog, EventMesh Workflow Engine and EventMesh Runtime are running in three different processors.
![eventmesh-workflow-arch](../../images/features/eventmesh-workflow-arch.jpg?raw=true)
The steps running the workflow is the followings:
1. Deploy the Publisher and Subscriber Apps in the environment.
Describe the App APIs using AsyncAPI, generate the asyncAPI yaml.
Register the Publisher and Subscriber Apps in EventMesh Catalog using AsyncAPI.
2. Register the Serverless Workflow DSL in EventMesh Workflow Engine.
3. EventMesh Workflow Engine query the EventMesh Catalog for Publisher and Subscribers required in Workflow DSL `function`


4. Event-driven Apps are publish events to EventMesh Runtime to trigger the Workflow. EventMesh Workflow Engine also publish and subscribe events for orchestrating the events.


### EventMesh Catalog Design

EventMesh Catalog store the Publisher, Subscriber and Channel metadata. consists of the following modules:

- AsyncAPI Parser

Using the SDK provided by AsyncAPI community (see [tool list](https://www.asyncapi.com/docs/community/tooling)),
parse and validated the AsyncAPI yaml inputs, and generate the AsyncAPI definition.


- Publisher, Channel, Subscriber Modules

From the AsyncAPI definition store the Publisher, Subscriber and Channel information.


### EventMesh Workflow Engine Design

EventMesh Workflow Engine consists of the following modules:

- Workflow Parser

Using the SDK provided by Serverless Workflow community (see supported [SDKs](https://github.com/serverlessworkflow/specification#sdks)),
parse and validated the workflow DSL inputs, and generate workflow definition.


- Workflow Module

It manages a workflow instance life cycle, from create, start, stop to destroy.


- State Module

It manages workflow state life cycle. We support the event-related states, and the supported state list below is Work-in-Progress.

| Workflow State | Description |
| --- | --- |
| Operation | Execute the AsyncAPI functions defined in the Actions |
| Event | Check if the defined Event matched, if so execute the defined AsyncAPI functions |
| Switch | Check the event is matched with the event-conditions, and execute teh defined AsyncAPI functions |
| Parallel | Execute the defined AsyncAPI functions in parallel |
| ForEach | Iterate the inputCollection and execute the defined AsyncAPI functions |

- Action Module

It managed the functions inside the action.


- Function Module

It manages the AsyncAPI functions by creating the publisher and/or subscriber in EventMesh Runtime, and manage the publisher/subscriber life cycle.

| AsyncAPI Operation | EventMesh Runtime |
| --- | --- |
| Publish | Publisher |
| Subscribe | Subscriber |


- Event Module

It manages the CloudEvents data model, including event filter, correlation and transformation using the rules defined in the workflow DSL.


- Retry Module

It manages the retry logic of the event publishing into EventMesh Runtime.
8 changes: 4 additions & 4 deletions docs/en/instructions/eventmesh-runtime-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ message RequestHeader {
string protocolDesc = 12;
}
message EventMeshMessage {
message SimpleMessage {
RequestHeader header = 1;
string producerGroup = 2;
string topic = 3;
Expand Down Expand Up @@ -391,10 +391,10 @@ message Heartbeat {
```
service PublisherService {
# Async event publish
rpc publish(EventMeshMessage) returns (Response);
rpc publish(SimpleMessage) returns (Response);
# Sync event publish
rpc requestReply(EventMeshMessage) returns (Response);
rpc requestReply(SimpleMessage) returns (Response);
# Batch event publish
rpc batchPublish(BatchMessage) returns (Response);
Expand All @@ -409,7 +409,7 @@ service ConsumerService {
rpc subscribe(Subscription) returns (Response);
# The subscribed event will be delivered through stream of Message
rpc subscribeStream(Subscription) returns (stream EventMeshMessage);
rpc subscribeStream(Subscription) returns (stream SimpleMessage);
rpc unsubscribe(Subscription) returns (Response);
}
Expand Down
Loading

0 comments on commit 7332d24

Please sign in to comment.