Skip to content

Commit

Permalink
Upgrade to CloudEvents 2.0 (#11)
Browse files Browse the repository at this point in the history
Signed-off-by: ruromero <[email protected]>
  • Loading branch information
ruromero authored Sep 3, 2020
1 parent 5b6381d commit f6f6311
Show file tree
Hide file tree
Showing 21 changed files with 400 additions and 653 deletions.
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ KNative Eventing environment so that users can monitor received events in the Ac
also send events of the desired type to see if it is being forwarded back to the application through
the broker.

The application has a web interface in which you can define the events you want to send to the broker:

![create event](docs/images/create_event.png)

In the right-hand side all the emitted and received events will be listed. In the image below there are two received
and one emitted event.

![activity](docs/images/activity.png)

And you will also be able to display the payload of the event.

![event](docs/images/event.png)

## Build and run the application

The application can be configured to send events to itself to ensure that both send/receive
Expand Down Expand Up @@ -113,13 +126,13 @@ mvn clean package -PskipFrontend
### JVM version

```shell script
docker build -t ruromero/cloudevents-player-jdk8:latest -f src/main/docker/Dockerfile.jvm .
podman build -t ruromero/cloudevents-player-jdk8:latest -f src/main/docker/Dockerfile.jvm .
```

### Native version

```shell script
docker build -t ruromero/cloudevents-player:latest -f src/main/docker/Dockerfile.native .
podman build -t ruromero/cloudevents-player:latest -f src/main/docker/Dockerfile.native .
```

## Running CloudEvents Player on Kubernetes
Expand All @@ -134,7 +147,7 @@ docker build -t ruromero/cloudevents-player:latest -f src/main/docker/Dockerfile
Use [deploy_native.yaml](./src/main/knative/deploy_native.yaml) to create the resources

```shell script
$ kubectl apply -n myproject -f src/main/knative/deploy_native.yaml
$ kubectl apply -n myproject -f src/main/knative/deploy.yaml
service.serving.knative.dev/cloudevents-player created
trigger.eventing.knative.dev/cloudevents-player created
```
Expand Down
Binary file added docs/images/activity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/create_event.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/event.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
103 changes: 37 additions & 66 deletions frontend/__mocks__/examples/messages.json
Original file line number Diff line number Diff line change
@@ -1,97 +1,68 @@
[
{
"event": {
"attributes": {
"datacontenttype": "application/json",
"id": "7c30a718-0456-45c1-b418-b7c3dfcd8d3f",
"mediaType": "application/json",
"source": "mock-server",
"specversion": "1.0",
"type": "org.example.types.foo"
},
"data": { "message": "Hello CloudEvents!" }
},
"id": "7c30a718-0456-45c1-b418-b7c3dfcd8d3f",
"subject": "subject 1",
"source": "mock-server",
"type": "org.example.types.foo",
"data": {
"message": "Hello CloudEvents!"
},
"receivedAt": "2019-12-02T13:16:51.376+01:00[Europe/Madrid]",
"type": "RECEIVED"
},
{
"event": {
"attributes": {
"datacontenttype": "application/json",
"id": "7c30a718-0456-45c1-b418-b7c3dfcd8d3f",
"mediaType": "application/json",
"source": "mock-server",
"specversion": "1.0",
"type": "org.example.types.foo"
},
"data": { "message": "Hello CloudEvents!" }
},
"id": "7c30a718-0456-45c1-b418-b7c3dfcd8d3f",
"subject": "subject 1",
"source": "mock-server",
"type": "org.example.types.foo",
"data": {
"message": "Hello CloudEvents!"
},
"receivedAt": "2019-12-02T13:16:51.366+01:00[Europe/Madrid]",
"type": "SENT"
},
{
"event": {
"attributes": {
"datacontenttype": "application/json",
"id": "e783bf4c-92e3-419e-bd79-bc18eb783b2c",
"mediaType": "application/json",
"source": "mock-server",
"specversion": "1.0",
"type": "org.example.types.bar"
},
"data": { "message": "Hello CloudEvents!" }
},
"id": "e783bf4c-92e3-419e-bd79-bc18eb783b2c",
"subject": "subject 1",
"source": "mock-server",
"specversion": "1.0",
"eventType": "org.example.types.bar",
"data": {
"message": "Hello CloudEvents!"
},
"receivedAt": "2019-12-02T13:16:50.203+01:00[Europe/Madrid]",
"type": "RECEIVED"
},
{
"event": {
"attributes": {
"datacontenttype": "application/json",
"id": "e783bf4c-92e3-419e-bd79-bc18eb783b2c",
"mediaType": "application/json",
"source": "mock-server",
"specversion": "1.0",
"type": "org.example.types.bar"
},
"data": { "message": "Hello CloudEvents!" }
},
"id": "e783bf4c-92e3-419e-bd79-bc18eb783b2c",
"subject": "subject 2",
"source": "mock-server",
"eventType": "org.example.types.bar",
"data": {
"message": "Hello CloudEvents!"
},
"receivedAt": "2019-12-02T13:16:50.171+01:00[Europe/Madrid]",
"type": "SENT"
},
{
"event": {
"attributes": {
"datacontenttype": "application/json",
"id": "1038fe8b-f1a4-4a04-9722-73254c78f414",
"mediaType": "application/json",
"source": "mock-server",
"specversion": "1.0",
"type": "org.example.types.baz"
},
"data": { "message": "Hello CloudEvents!" }
},
"id": "1038fe8b-f1a4-4a04-9722-73254c78f414",
"subject": "subject 2",
"source": "mock-server",
"type": "org.example.types.baz",
"data": {
"message": "Hello CloudEvents!"
},
"receivedAt": "2019-12-02T13:16:49.115+01:00[Europe/Madrid]",
"type": "RECEIVED"
},
{
"event": {
"attributes": {
"datacontenttype": "application/json",
"id": "1038fe8b-f1a4-4a04-9722-73254c78f414",
"mediaType": "application/json",
"source": "mock-server",
"specversion": "1.0",
"type": "org.example.types.baz"
},
"data": { "message": "Hello CloudEvents!" }
},
"id": "1038fe8b-f1a4-4a04-9722-73254c78f414",
"subject": "subject 2",
"source": "mock-server",
"type": "org.example.types.baz",
"data": {
"message": "Hello CloudEvents!"
},
"receivedAt": "2019-12-02T13:16:48.766+01:00[Europe/Madrid]",
"type": "SENT"
}
Expand Down
12 changes: 8 additions & 4 deletions frontend/src/components/Activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ const Activity = () => {
<TableRow>
<TableCell>ID</TableCell>
<TableCell>Type</TableCell>
<TableCell>Subject</TableCell>
<TableCell>Source</TableCell>
<TableCell>Status</TableCell>
<TableCell>Time</TableCell>
Expand All @@ -136,13 +137,16 @@ const Activity = () => {
{messages.map((message, rowId) => (
<TableRow key={rowId}>
<TableCell component="th" scope="row">
{message.id}
{message.id || "-"}
</TableCell>
<TableCell component="th" scope="row">
{message.event.attributes.type}
{message.eventType || "-"}
</TableCell>
<TableCell component="th" scope="row">
{message.event.attributes.source}
{message.subject || "-"}
</TableCell>
<TableCell component="th" scope="row">
{message.source || "-"}
</TableCell>
<TableCell component="th" scope="row">
<EventTypeIcon type={message.type} />
Expand All @@ -151,7 +155,7 @@ const Activity = () => {
{message.receivedAt}
</TableCell>
<TableCell component="th" scope="row">
<ViewEvent event={message.event} />
<ViewEvent event={message.data} />
</TableCell>
</TableRow>
))}
Expand Down
11 changes: 10 additions & 1 deletion frontend/src/components/EventSender.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const EventSender = () => {
setDirty({
id: true,
type: true,
subject: true,
source: true,
specversion: true,
message: true
Expand All @@ -81,6 +82,7 @@ const EventSender = () => {
"Content-Type": "application/json",
"ce-id": values.id,
"ce-type": values.type,
"ce-subject": values.subject,
"ce-source": values.source,
"ce-specversion": values.specversion
},
Expand Down Expand Up @@ -131,6 +133,14 @@ const EventSender = () => {
value={values.type || ""}
onChange={event => onValueChanged(event.target.value, "type")}
/>
<TextField
label="Event Subject"
id="subject"
className={classes.textField}
margin="normal"
value={values.subject || ""}
onChange={event => onValueChanged(event.target.value, "subject")}
/>
<TextField
required
error={showError("source")}
Expand All @@ -156,7 +166,6 @@ const EventSender = () => {
>
<MenuItem value="1.0">1.0</MenuItem>
<MenuItem value="0.3">0.3</MenuItem>
<MenuItem value="0.2">0.2</MenuItem>
</Select>
</FormControl>
<TextField
Expand Down
Loading

0 comments on commit f6f6311

Please sign in to comment.