2 stable releases

1.0.1 Oct 8, 2024
1.0.0 Oct 6, 2024

#444 in Concurrency

Download history 116/week @ 2024-10-01 212/week @ 2024-10-08 3/week @ 2024-10-15

242 downloads per month

Apache-2.0

25KB
440 lines

Thread-safe ZeroMQ

This implementation is based on Golang's zmqchan, all the credit should go the the author of zmqchan

This is just a tweaked implementation in Rust

Message Flow

                        +-------------------+
                        |     Client        |
                        +-------------------+
                                    |
                                    v
                            (Client Sends Message)
                                    |
+-----------------------------------v----------------------------------------+
|                          ChannelPair                                       |
|                                                                            |
|                           +--------------+                                 |
|                           |    z_sock    |                                 |
|                           | (ZeroMQ SOCK)|                                 |
|                           +--------------+                                 |
|                                   |                                        |
|                                   v                                        |
|                     (Message Forwarded to Channel)                         |
|                                   |                                        |
|                          +--------------+                                  |
|                          |   channel    |                                  |
|                          | (Crossbeam   |                                  |
|                          |   Channel)   |                                  |
|                          +--------------+                                  |
|                                   |                                        |
|                                   v                                        |
|                    (Message Consumed by `z_tx[IN]`)                        |
|                           +---------------+                                |
|                           |   z_tx[IN]    |                                |     
|                           | (PAIR Socket) |                                | 
|                           +---------------+                                |
|                                   |                                        |
|                                   |                                        |
|                       (Message Sent to `z_tx[OUT]`)                        |                        
|                                   |                                        |
|                                   v                                        | 
|                           +---------------+                                |
|                           |   z_tx[OUT]   |                                |
|                           | (PAIR Socket) |                                |
|                           +---------------+                                |
|                    (Message Passed to `z_sock`)                            |
|                                   |                                        |
|                                   |                                        |
|                    (Message Prepared for `z_sock`)                         |
|                                   v                                        |
|                           +--------------+                                 |
|                           |   z_sock     |                                 |
|                           | (Writable)   |                                 |
|                           +--------------+                                 |
|                                   |                                        |
|                    (Message Sent Back to Client)                           |
|                                   |                                        |
+----------------------------------------------------------------------------+
                                    |
                                    v
                        (Client Receives Response)
                                    |
                            +-------------------+
                            |      Client       |
                            +-------------------+

Dependencies

~0.5–2.3MB
~37K SLoC