diff options
Diffstat (limited to 'content')
| -rw-r--r-- | content/2020-03-22-simple-sse-based-pubsub-server.md | 8 | ||||
| -rw-r--r-- | content/2020-03-27-create-placeholder-images-with-sharp.md | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/content/2020-03-22-simple-sse-based-pubsub-server.md b/content/2020-03-22-simple-sse-based-pubsub-server.md index 945b4dd..d7bd451 100644 --- a/content/2020-03-22-simple-sse-based-pubsub-server.md +++ b/content/2020-03-22-simple-sse-based-pubsub-server.md | |||
| @@ -23,7 +23,7 @@ The easiest way to explain this is with diagram bellow. Basic function is simple | |||
| 23 | 23 | ||
| 24 |  | 24 |  |
| 25 | 25 | ||
| 26 | **ⓘ** These are some naive characteristics we want to achieve: | 26 | **These are some naive characteristics we want to achieve:** |
| 27 | 27 | ||
| 28 | - producer is publishing messages to subscribe topic, | 28 | - producer is publishing messages to subscribe topic, |
| 29 | - consumer is receiving messages from subscribed topic, | 29 | - consumer is receiving messages from subscribed topic, |
| @@ -35,7 +35,7 @@ The easiest way to explain this is with diagram bellow. Basic function is simple | |||
| 35 | - producer can publish to multiple topics, | 35 | - producer can publish to multiple topics, |
| 36 | - each message has a messageId. | 36 | - each message has a messageId. |
| 37 | 37 | ||
| 38 | **ⓘ** Known drawbacks: | 38 | **Known drawbacks:** |
| 39 | 39 | ||
| 40 | - messages will not be stored in a persistent queue or unreceived messages like [DeadLetterQueue](https://en.wikipedia.org/wiki/Dead_letter_queue) so old messages could be lost on server restart, | 40 | - messages will not be stored in a persistent queue or unreceived messages like [DeadLetterQueue](https://en.wikipedia.org/wiki/Dead_letter_queue) so old messages could be lost on server restart, |
| 41 | - [Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events) opens a long-running connection between the client and the server so make sure if your setup is load balanced that the load balancer in this case can have long opened connection, | 41 | - [Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events) opens a long-running connection between the client and the server so make sure if your setup is load balanced that the load balancer in this case can have long opened connection, |
| @@ -103,7 +103,7 @@ Connection: keep-alive | |||
| 103 | 103 | ||
| 104 | Google Chrome provides build-in debugging and exploration tool for [Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events) which is quite nice and available from Developer Tools under Network tab. | 104 | Google Chrome provides build-in debugging and exploration tool for [Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events) which is quite nice and available from Developer Tools under Network tab. |
| 105 | 105 | ||
| 106 | **ⓘ** You can debug only client side events that get received and not the server ones. | 106 | > You can debug only client side events that get received and not the server ones. For debugging server events add `console.log` to `server.js` code and print out events. |
| 107 | 107 | ||
| 108 |  | 108 |  |
| 109 | 109 | ||
| @@ -318,7 +318,7 @@ Subscriber is responsible for receiving new messages that come from server via p | |||
| 318 | 318 | ||
| 319 | You can use either Developer Tools Console to see incoming messages or you can defer to Debugging with Google Chrome section above to see all EventStream messages. | 319 | You can use either Developer Tools Console to see incoming messages or you can defer to Debugging with Google Chrome section above to see all EventStream messages. |
| 320 | 320 | ||
| 321 | **ⓘ** Don't be alarmed if the subscriber gets disconnected from the server every so often. The code we have here resets connection every 15s but it automatically get reconnected and fetches all messages up to last received message id. This setting can be adjusted in `server.js` file; search for the `maxStreamDuration` variable. | 321 | > Don't be alarmed if the subscriber gets disconnected from the server every so often. The code we have here resets connection every 15s but it automatically get reconnected and fetches all messages up to last received message id. This setting can be adjusted in `server.js` file; search for the `maxStreamDuration` variable. |
| 322 | 322 | ||
| 323 | ```html | 323 | ```html |
| 324 | <!DOCTYPE html> | 324 | <!DOCTYPE html> |
diff --git a/content/2020-03-27-create-placeholder-images-with-sharp.md b/content/2020-03-27-create-placeholder-images-with-sharp.md index 1386b2f..ec6fadd 100644 --- a/content/2020-03-27-create-placeholder-images-with-sharp.md +++ b/content/2020-03-27-create-placeholder-images-with-sharp.md | |||
| @@ -49,7 +49,7 @@ All this code was wrapped inside a web service with some additional security che | |||
| 49 | 49 | ||
| 50 | And at that point I needed to return placeholder images as a response in case key is missing or x,y are not allowed by the server etc. I could have created PNG in Gimp and just serve them but I wanted to respect aspect ratio and I didn't want to return some mangled images. | 50 | And at that point I needed to return placeholder images as a response in case key is missing or x,y are not allowed by the server etc. I could have created PNG in Gimp and just serve them but I wanted to respect aspect ratio and I didn't want to return some mangled images. |
| 51 | 51 | ||
| 52 | **ⓘ** Main problem with finding a clean solution I could copy and paste and change a bit was a task. API is changing constantly and there weren't clear examples or I was unable to find them. | 52 | > Main problem with finding a clean solution I could copy and paste and change a bit was a task. API is changing constantly and there weren't clear examples or I was unable to find them. |
| 53 | 53 | ||
| 54 | ## Generating placeholder images using SVG | 54 | ## Generating placeholder images using SVG |
| 55 | 55 | ||
| @@ -80,4 +80,4 @@ const generatePlaceholderImageWithText = async (width, height, message) => { | |||
| 80 | 80 | ||
| 81 | That is about it. Nothing more to it. You can change the color of the image by changing `background` and if you want to change text styling you can adapt SVG to your needs. | 81 | That is about it. Nothing more to it. You can change the color of the image by changing `background` and if you want to change text styling you can adapt SVG to your needs. |
| 82 | 82 | ||
| 83 | **ⓘ** Also be careful about the length of the text. This function positions text at the center and adds `20px` padding on all sides. If text is longer than the image it will get cut. | 83 | > Also be careful about the length of the text. This function positions text at the center and adds `20px` padding on all sides. If text is longer than the image it will get cut. |
