You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to add functionality to compress and decompress messages during transit, we need to know what a message actually is and how it is implemented.
53
-
Iggy implements two important types, that we need to know.
53
+
Iggy implements two important types that we need to know.
A message send to the server needs to be of type `IggyMessage`.
58
+
A message sent to the server needs to be of type `IggyMessage`.
59
59
60
60
```Rust
61
61
pub struct IggyMessage {
@@ -71,17 +71,17 @@ pub struct IggyMessage {
71
71
The important bits in context of this example are the *payload* and the *user_headers*.
72
72
Payload is of type Bytes and corresponds to the actual message that we want to send to the server.
73
73
74
-
Let's suppose our example is an abstraction over a real world scenario, where some application sends it's application logs to the iggy-server. This application is therefore the producer.
74
+
Let's suppose our example is an abstraction over a real world scenario, where some application sends its application logs to the iggy-server. This application is therefore the producer.
75
75
We also have a monitoring service, that inspects the logs of our application to check for any service disruptions. So this monitoring service needs to read the logs from the iggy-server and is therefore the consumer.
76
76
77
77
Further suppose, the application logs are quite large and repetitive, since they follow a structured pattern (as logs usually do).
78
-
It may be a good idea to reduce bandwidth by trading of some idle CPU time to compress the logs before sending them to the server.
78
+
It may be a good idea to reduce bandwidth by trading off some idle CPU time to compress the logs before sending them to the server.
79
79
We go straight ahead, implement some compression functionalities and send the compressed messages to the server.
80
80
If the monitoring service now consumes these messages we have a problem. The logs are still compressed.
81
81
Even if we know that the messages are compressed we do not know how to decompress them because the algorithm that was used for compression is unknown.
82
82
83
83
This is where `user_headers` become handy.
84
-
The definition above tells us, that user_headers are (optional) Bytes. But thats because finally everything is serialized before sending to the server.
84
+
The definition above tells us that user_headers are (optional) Bytes. But that's because finally everything is serialized before sending to the server.
85
85
Looking at the implementation of `IggyMessage` we see that user_headers are a serialized `HashMap` with Iggy specific types `HeaderKey` and `HeaderValue`.
86
86
So the user_headers are basically a set of metadata defined by us, the user, using a key and a value.
0 commit comments