DB2: Tokio Mini Redis — Commands (Part 4)
Hopefully, this will conclude the exploration into mini-redis. The topic would mainly focus on the command folder.
cmd/mod.rs
- convert the
frame
to Command object apply()
the commandget_name()
returns the command name
cmd/get.rs
- new
- key (GET specific function)
- parse_frames (called in from_frame inside
mod.rs
) - apply (
command
pattern apply) - into_frame ( complemented by
from
)
cmd/ping.rs
dst
here is destination connection
cmd/publish.rs
cmd/set.rs
cmd/unknown.rs
cmd/subscribe.rs
This is the ugliest frog in the commands. May revisit this class later, to understand more.
Contains
- subscribe : Subscribes the client to one or more channels.
- unsubscribe : Unsubscribes the client from one or more channels.
Lets understand some of the terms in subscribe.
Pin:
Send + Sync
in rust.
Stream
trait
Drain:
StreamMap:
extend:
Select!:
async_stream::stream!
Conclusion:
We have kind of visited mini-redis on a high level. The content was just an introduction to a mini-project in rust. It gave a brief overview of a lot of concepts in rust, tokio, and async programming. Hopefully, the next sessions would go a little deeper into the code.
Found it Interesting?
Please show your support by 👏