pub struct Endpoint {
pub middlewares: Vec<Middleware>,
pub endpoint_type: EndpointType,
pub handler: Option<Arc<dyn Handler>>,
}Expand description
Represents a connection point for messages, which can be a source (input) or a sink (output).
Fields§
§middlewares: Vec<Middleware>(Optional) A list of middlewares to apply to the endpoint.
endpoint_type: EndpointTypeThe specific endpoint implementation, determined by the configuration key (e.g., “kafka”, “nats”).
handler: Option<Arc<dyn Handler>>Internal handler for processing messages (not serialized).
Implementations§
Source§impl Endpoint
impl Endpoint
pub fn new(endpoint_type: EndpointType) -> Self
Sourcepub fn new_memory(topic: &str, capacity: usize) -> Self
pub fn new_memory(topic: &str, capacity: usize) -> Self
Creates a new in-memory endpoint with the specified topic and capacity.
§Examples
use mq_bridge::models::Endpoint;
let endpoint = Endpoint::new_memory("my_topic", 100);pub fn new_response() -> Self
pub fn add_middleware(self, middleware: Middleware) -> Self
pub fn add_middlewares(self, middlewares: Vec<Middleware>) -> Self
Sourcepub fn channel(&self) -> Result<MemoryChannel>
pub fn channel(&self) -> Result<MemoryChannel>
Returns a reference to the in-memory channel associated with this Endpoint. This function will only succeed if the Endpoint is of type EndpointType::Memory. If the Endpoint is not a memory endpoint, this function will return an error. This function is primarily used for testing purposes where a Queue is needed.
pub fn null() -> Self
pub async fn create_consumer( &self, route_name: &str, ) -> Result<Box<dyn MessageConsumer>>
pub async fn create_publisher(&self, _route_name: &str) -> Result<Publisher>
pub fn check_consumer( &self, route_name: &str, allowed_endpoints: Option<&[&str]>, ) -> Result<()>
pub fn check_publisher( &self, route_name: &str, allowed_endpoints: Option<&[&str]>, ) -> Result<()>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Endpoint
impl<'de> Deserialize<'de> for Endpoint
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Endpoint
impl !RefUnwindSafe for Endpoint
impl Send for Endpoint
impl Sync for Endpoint
impl Unpin for Endpoint
impl !UnwindSafe for Endpoint
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more