Skip to content

Commit 1ce3a07

Browse files
authored
Update NQ example (code & docs) (#399)
Towards OND-1483
1 parent 0ba5cf4 commit 1ce3a07

File tree

2 files changed

+27
-18
lines changed

2 files changed

+27
-18
lines changed

java/com/engflow/notificationqueue/Client.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,10 @@ public void onNext(PullNotificationResponse response) {
153153
BuildLifecycleEventNotification lifeCycleEvent =
154154
notificationContent.unpack(BuildLifecycleEventNotification.class);
155155
/**
156-
* Check if this is an invocation started event. Options are INVOCATION_STARTED and
157-
* INVOCATION_FINISHED
156+
* Check if this is an invocation finished event.
158157
*/
159-
if (lifeCycleEvent.getKindCase().name().equals("INVOCATION_STARTED")) {
160-
String invocation = lifeCycleEvent.getInvocationStarted().getInvocationId();
158+
if (lifeCycleEvent.getKindCase().name().equals("INVOCATION_FINISHED")) {
159+
String invocation = lifeCycleEvent.getInvocationFinished().getInvocationId();
161160
try {
162161
/**
163162
* Fetch the invocation using the grpc {@link EventStoreGrpc} stub using the

java/com/engflow/notificationqueue/README.md

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ getting lifecycle events from the cluster, we pull from the queue called `lifecy
1818
2. `--queue_name=eventstore/lifecycle-events` holds the name of the queue to listen
1919

2020
Next, you must provide authentication information so the client can establish
21-
a connection to the engflow cluster, unless the cluster is totally open.
21+
a connection to the EngFlow cluster, unless the cluster is totally open.
2222
As for today, two authentication methods are available; certificates or
2323
authentication tokens. These arguments are optional and if they are not given
2424
but are required by the cluster, the connection is rejected.
@@ -106,32 +106,42 @@ bazel build //... '--remote_cache=grpcs://example.cluster.engflow.com' '--bes_ba
106106
You should see a series of notifications like this one
107107

108108
```json
109-
type_url: "type.googleapis.com/engflow.eventstore.v1.BuildLifecycleEventNotification"
110-
value: "\022$e03d2afe-1a78-4f14-a0f7-85ae65e7e856\"%user_keyword=engflow:StreamSource=BES\"/user_keyword=engflow:StreamType=ClientBEPStream\272\006&\n$1e4f34ee-4669-4ce0-a3fe-5e115ad4772e"
109+
{
110+
type_url: "type.googleapis.com/engflow.eventstore.v1.BuildLifecycleEventNotification"
111+
value: "\n\adefault\022$9608f439-4c3e-4909-8a0c-f78810322b6b\"\021command_name=test\"\021protocol_name=BEP\"0user_keyword=engflow:CiCdPipelineName=post-merge\"7user_keyword=engflow:CiCdJobName=ci-runners-test-matrix\"\'user_keyword=engflow:Requester=anfelbar\"%user_keyword=engflow:StreamSource=BES\"/user_keyword=engflow:StreamType=ClientBEPStream\272\006&\n$5173658c-4595-4978-8db0-2942b1e7ca13"
112+
}
111113
```
112114

113-
The value, with some garbage characters, contains the uuid for one invocation.
114-
Using this uuid we may get an invocation like this one
115+
The last value contains the `uuid` for one invocation. From the previous example the invocation `uuid` is `5173658c-4595-4978-8db0-2942b1e7ca13`.
116+
Using this `uuid` and the EventStore stub we get invocation data (see [getInvocations code in Client.java][getinvocations]):
115117

116118
```json
117-
StreamedBuildEvent: continuation_token: "CiQyMWFjMDlkNC0zZWIzLTQ2MzQtODI0MS0yMzk0Y2JhN2UwMGEQARjSCiAB"
119+
Invocation: continuation_token: "CiQwNzBkMjViZi0zZWFjLTRlYTYtODVhOC00ZjA2NDMxNjU2NTcQAA=="
118120
event {
119121
stream_id {
120-
build_id: "c88d85cb-08c5-4227-9a24-8e6ea8f262d8"
121-
component: TOOL
122-
invocation_id: "21ac09d4-3eb3-4634-8241-2394cba7e00a"
122+
build_id: "3a38c04f-233d-465f-a91d-f328c21ab832"
123+
invocation_id: "070d25bf-3eac-4ea6-85a8-4f0643165657"
123124
}
125+
service_level: INTERACTIVE
126+
notification_keywords: "command_name=test"
127+
notification_keywords: "protocol_name=BEP"
128+
notification_keywords: "user_keyword=engflow:CiCdPipelineName=post-merge"
129+
notification_keywords: "user_keyword=engflow:CiCdJobName=runners-matrix"
130+
notification_keywords: "user_keyword=engflow:Requester=userxyz"
131+
notification_keywords: "user_keyword=engflow:StreamSource=BES"
132+
notification_keywords: "user_keyword=engflow:StreamType=ClientBEPStream"
124133
build_event {
125134
event_time {
126-
seconds: 1658502561
127-
nanos: 364000000
135+
seconds: 1752547458
136+
nanos: 781000000
128137
}
129-
component_stream_finished {
130-
type: FINISHED
138+
invocation_attempt_started {
139+
attempt_number: 1
131140
}
132141
}
133142
}
134143
```
135144

136145

137-
[server proto definition]: demoserver/server.proto
146+
[server proto definition]: demoserver/server.proto
147+
[getinvocations]: https://github.com/EngFlow/example/blob/c9a30c214d487385313245cca24c6b7f3e867785/java/com/engflow/notificationqueue/Client.java#L201

0 commit comments

Comments
 (0)