Closed
Conversation
52afc35 to
828bfbd
Compare
Add `tokio` crate as a dependency. Signed-off-by: OJarrisonn <j.h.m.t.v.10@gmail.com>
Here i've created the implementation of the logger actor. This actor is responsible for logging messages. The `Logger` struct is a simple refactor of the old `app::logging::Logger` it is responsible for storing messages that will be later printed to the stdout and also to provide methods such as `spawn` `spawn` is responsible for creating a dedicated task that will handle all the messages received from all the transmitters. The `LoggerTx` is a transmitter that is responsible by sending messages down to the running actor. This is what should be used accross the code base to communicate with the actor. The `MockLoggerTx` is a mock version of this logger which does nothing at all. Finally but not least, the `LoggerActor` trait which unifies the interface of `LoggerTx` and `MockLoggerTx`. This permits the swaping of the loggers for testing scenarios. Signed-off-by: OJarrisonn <j.h.m.t.v.10@gmail.com>
Removes the old logger implementation for cleanup purposes Signed-off-by: OJarrisonn <j.h.m.t.v.10@gmail.com>
Adapts the `utils` testing module to support the new async setup function. Signed-off-by: OJarrisonn <j.h.m.t.v.10@gmail.com>
Adds a simple description to the `logger` field in the `App` struct Signed-off-by: OJarrisonn <j.h.m.t.v.10@gmail.com>
828bfbd to
45cfd35
Compare
This actor is a way to improve patch-hub testing suit. It's just a wrapper to `std::env` to let us manipulate environment variables. But it also has a mock variant which won't touch the real environment variables but use a simple `HashMap` instead With this, the later config tests can be run in parallel Signed-off-by: OJarrisonn <j.h.m.t.v.10@gmail.com>
The config actor will be responsible for managing config options in patch-hub. It's a simple store with capability to handle data serialization and deserialization. Signed-off-by: OJarrisonn <j.h.m.t.v.10@gmail.com>
Adapts the code to use the new config actor instead of the old config implementation. This mean that several functions became async. There is a little trick that will be solve later since we cannot use async functions to draw on the terminal so we pass the `page_size` value directly instead of gathering it from the `app.config` in the `draw_ui` function. Signed-off-by: OJarrisonn <j.h.m.t.v.10@gmail.com>
Deletes the old config files and move/adapt the config files to the new config Signed-off-by: OJarrisonn <j.h.m.t.v.10@gmail.com>
45cfd35 to
a33f515
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In this PR i'm drafting my proposal to use the actor model with the
Config. Several minor refactors where done (akaasync fn/await) all over the code. But the core of this is the design chosen for the config actor.The design
We still have a
Configstruct and most of the methods implemented before. But the getters and setters where changed. The actor model consists of messages being passed around, since most config options are strings, i thought it would be useful to use a single message to handle both getting/setting a string, just created a enumStringOptto identify which option we wanna handle. Same forusizeconfig options. For other options I created messages for each of them.The
ConfigActortrait behaves similar to theLoggerActortrait, by abstracting the call tosend. But this time most messages are async, since most of them return a response. And this reminds me of clarifying the response model adopted.Response Model
Again, the actor model is all about sending and receiving responses. So far we defined how to send messages, by using a
tokio::sync::mspc::Sender<Command>and catching it in a dedicated task. So for messages that need a response, we will have atokio::sync::oneshot::Sender<T>in the payload of the message, this way the receiver has a channel to send a response back with any value we need. The only drawback is that we cannot use&. So to return a string from out configuration, we need to clone it. But since our strings are not that long, it won't be a huge performance hit. It will be worse, of course, but not theThis approach is the one i'm sticking to during the continuation of this project and hope other developers keep this pattern
TODO