From c763ae50a8985d8bf419110d4a97cfa30af8ed38 Mon Sep 17 00:00:00 2001 From: Christian Raphael Heryanto <christian.raphael@ui.ac.id> Date: Fri, 28 Mar 2025 16:48:51 +0800 Subject: [PATCH] Refletion Subscriber-2 --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index b2bf967..eaa9f64 100644 --- a/README.md +++ b/README.md @@ -96,3 +96,24 @@ Static variables in Rust guarantess Memory Safety and thread safety during compi Unlike Java, Rust's approach doesn't allow static mutability as it might cause potential data races. #### Reflection Subscriber-2 + +##### Exploration + +I explored things outside the tutorial. Parts in which I find amusing a as follows: +- Configuration management is done in the app config struct and lazy static pattern with the goal of a thread-asfe singleton configuration. +- Error handling is provided by tje custom error response pattern in lib.rs +- REQWEST_CLIENT is a global which create shared resources to prevent creation of resources in every request. + +##### Observer Pattern and Multiple Subscribers + +The Observer pattern significantly simplifies adding more subscribers, which are: + +1. Publishers and subscribers have no direct dependencies on each other as they only know about the notification format. + +2. New subscribers can join or leave at runtime without requiring any code changes to the publisher. + +3. All notification uses the same HTTP endpoint format, making it easy to add more instances. + +##### Testing and Documentation + +I've done several tests, one of which is a test on my CTF question. It helps me develop things quickly and ensure that my program run as intended, which in case. The feature environment variables helps alot in testing both local and remote url. By defining a base url, we can switch url without having to change every base url in each of the tests in the collection. -- GitLab