Skip to content

Commit 59d6a22

Browse files
committed
Update course definition to clarify correlation ID parsing and request structure.
1 parent bd7097b commit 59d6a22

File tree

1 file changed

+33
-20
lines changed

1 file changed

+33
-20
lines changed

course-definition.yml

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -148,28 +148,34 @@ stages:
148148
name: "Parse Correlation ID"
149149
difficulty: medium
150150
description_md: |-
151-
In this stage, you'll continue implementing the Kafka wire protocol.
152-
The request structure is as follows:
151+
In this stage, you'll parse the correlation ID from the request and send a response with the same correlation ID.
153152
154-
RequestHeader: V1
153+
### Request header format
155154
156-
RequestHeader:
157-
RequestApiKey: INT16
158-
RequestApiVersion: INT16
159-
CorrelationId: INT32
160-
ClientId: NULLABLE_STRING
155+
In the previous stage, we saw that the request starts with a 4 byte length field, followed by the request header, and then the request body.
161156
162-
The request is structured as follows:
157+
The format of the request header is as follows:
163158
164-
```
165-
+---------------+--------------------+------------------+
166-
| MessageLength | RequestHeader | RequestBody |
167-
+---------------+--------------------+------------------+
168-
| INT32 | REQUEST_HEADER_V1 | REQUEST_BODY_V3 |
169-
+---------------+--------------------+------------------+
170-
```
159+
| Field Name | Field Type | Description |
160+
|-----------------------|-----------------|-------------------------------------------|
161+
| `request_api_key` | INT16 | The API key for the request |
162+
| `request_api_version` | INT16 | The version of the API for the request |
163+
| `correlation_id` | INT32 | A unique identifier for the request |
164+
| `client_id` | NULLABLE_STRING | The client ID for the request |
171165
172-
In general each request in the Kafka wire protocol starts with a INT32 containing the length of the entire message, followed by the RequestHeader and then the RequestBody.
166+
- `request_api_key`: An integer identifying the type of request.
167+
- The value of this field is different for each type of request.
168+
- For example, the `APIVersions` request has a `request_api_key` of `18`.
169+
- A full list of API keys can be found in [the docs](https://kafka.apache.org/protocol.html#protocol_api_keys).
170+
- `request_api_version`: The version of the API for the request.
171+
- This is an integer that identifies the version of the API for the request.
172+
- For example, the `APIVersions` request supports multiple versions: `0`, `1`, `2` and `3`.
173+
- `correlation_id`: A unique identifier for the request.
174+
- This value is echo-ed back in the response.
175+
- (This is the value you hardcoded in the previous stage!)
176+
- `client_id`: A string identifying the client that sent the request.
177+
178+
In this stage, you'll only need to parse the `correlation_id` field. You can ignore the other fields for now.
173179
174180
### Tests
175181
@@ -179,11 +185,18 @@ stages:
179185
$ ./your_program.sh
180186
```
181187
182-
It'll then try to connect to your server on port 9092 and send a `APIVersions-V3` request. The tester will validate that the correlation ID in the response header matches
183-
the correlation ID in the request header.
188+
It'll then connect to your server on port 9092 and send a `APIVersions` request. The tester will include a random
189+
correlation ID in this request.
184190
185-
Although your server's response will need to contain the "message length" field (an int32), the tester will not verify this value in this stage.
191+
The tester will wait for your program to respond and it'll then validate that the correlation ID in the response header matches the correlation ID it send in the request header.
186192
193+
Just like the previous stage, the tester won't validate the first 4 bytes of your response (the "message length") in this stage.
194+
195+
### Notes
196+
197+
- You can remove the hardcoded correlation ID of `7` we used in the previous stage. You can now read this value from the request.
198+
- Since the response format is currently incomplete, the first 4 bytes of your response (the "message length") will not be validated in this stage. We'll get to this in later stages.
199+
- You don't need to parse all fields in the request in this stage, just the `correlation_id` field. We'll get to the other fields in later stages.
187200
marketing_md: |-
188201
In this stage, you'll start decoding the RequestHeader.
189202

0 commit comments

Comments
 (0)