Swap Eventbus for Engine to make the trait naming a bit clearer

This will help implementers understand that _they_ must bring the engine to
power the Bus :)
This commit is contained in:
R Tyler Croy 2020-06-21 12:47:16 -07:00
parent cc3885aed5
commit 61f5060e3f
2 changed files with 8 additions and 8 deletions

View File

@ -39,11 +39,11 @@ pub mod server {
pub type AsyncOptionMessage = Pin<Box<dyn Future<Output = Option<Message>> + Send + 'static>>;
pub struct Bus {
inner: Arc<dyn Eventbus>,
inner: Arc<dyn Engine>,
}
impl Bus {
pub fn new(inner: Arc<dyn Eventbus>) -> Self {
pub fn new(inner: Arc<dyn Engine>) -> Self {
Self { inner }
}
pub fn pending(
@ -73,7 +73,7 @@ pub mod server {
}
/**
* The Eventbus trait should be implemented by the servers which need to
* The Engine trait should be implemented by the servers which need to
* implement their own backing stores for an Otto eventbus.
*
* Each function is expected to return some sort of future that the caller
@ -83,7 +83,7 @@ pub mod server {
* can be used in many cases to help differentiate between consumers of the same
* topic, such as with Kafka consumer groups
*/
pub trait Eventbus {
pub trait Engine {
/**
* Return the number of messages the caller has not yet consumed
*/

View File

@ -1,5 +1,5 @@
/**
* This is the simplest implementation of an Otto Eventbus, which keeps everything
* This is the simplest implementation of an Otto Engine, which keeps everything
* only in memory
*/
#[deny(unsafe_code)]
@ -29,18 +29,18 @@ fn main() -> Result<(), std::io::Error> {
}
/**
* The MemoryBus is a simple implementation of the Eventbus trait for a totally
* The MemoryBus is a simple implementation of the Engine trait for a totally
* in-memory eventbus. There is no backing store and all data will be lost between
* restarts of the application.
*
* This is the most simple and primitive implementation of the Eventbus trait
* This is the most simple and primitive implementation of the Engine trait
*/
struct MemoryBus {
topics: Arc<DashMap<Topic, Vec<Message>>>,
offsets: Arc<DashMap<(Topic, CallerId), Offset>>,
}
impl Eventbus for MemoryBus {
impl Engine for MemoryBus {
fn pending(
self: Arc<Self>,
topic: Topic,