Skip to main content

Crate bevy_event_bus

Crate bevy_event_bus 

Source
Expand description

bevy_event_bus: Connect Bevy events to external message brokers

This crate provides an interface similar to Bevy’s MessageReader/MessageWriter but connected to external message brokers like Kafka.

Re-exports§

pub use backends::EventBusBackend;
pub use backends::event_bus_backend::StreamTrimStrategy;
pub use bus_message::BusMessage;
pub use config::Kafka;
pub use config::BackendMarker;
pub use config::EventBusConfig;
pub use config::InMemory;
pub use config::ProcessingLimits;
pub use config::TopologyMode;
pub use decoder::DecodedEvent;
pub use decoder::DecoderFn;
pub use decoder::DecoderRegistry;
pub use decoder::TypedDecoder;
pub use plugins::event_bus::BackendCapabilities;
pub use plugins::event_bus::BackendDownMessage;
pub use plugins::event_bus::BackendReadyMessage;
pub use plugins::event_bus::BackendStatus;
pub use plugins::event_bus::EventBusPlugin;
pub use backends::kafka_backend::KafkaEventBusBackend;
pub use backends::redis_backend::RedisAckWorkerStats;
pub use backends::redis_backend::RedisEventBusBackend;
pub use config::kafka::KafkaBackendConfig;
pub use config::kafka::KafkaChannelCapacities;
pub use config::kafka::KafkaConnectionConfig;
pub use config::kafka::KafkaConsumerConfig;
pub use config::kafka::KafkaConsumerGroupSpec;
pub use config::kafka::KafkaInitialOffset;
pub use config::kafka::KafkaMessageMetadata;
pub use config::kafka::KafkaProducerConfig;
pub use config::kafka::KafkaTopicSpec;
pub use config::kafka::KafkaTopologyConfig;
pub use config::kafka::UncommittedEvent;
pub use config::redis::RedisBackendConfig;
pub use config::redis::RedisConnectionConfig;
pub use config::redis::RedisConsumerConfig;
pub use config::redis::RedisConsumerGroupSpec;
pub use config::redis::RedisProducerConfig;
pub use config::redis::RedisRuntimeTuning;
pub use config::redis::RedisStreamSpec;
pub use config::redis::RedisTopologyBuilder;
pub use config::redis::RedisTopologyConfig;
pub use config::redis::RedisTopologyEventBinding;
pub use config::redis::TrimStrategy;

Modules§

backends
bus_message
Serializable payload types exchanged via the event bus.
config
Configuration system for backend-agnostic event bus readers and writers
decoder
Multi-decoder pipeline supporting multiple event types per topic
plugins
prelude
Re-export common items for convenience

Structs§

BusErrorContext
Context passed to error callbacks registered on writers/readers.
ConsumerMetrics
Basic consumer metrics (frame-scoped counters + cumulative stats).
DrainMetricsMessage
Emitted after each drain with snapshot metrics (optional for user systems).
DrainedTopicMetadata
Per-topic message buffers filled by the drain system and consumed by readers.
EventBusConsumerConfig
Configuration controlling how many events are drained each frame.
EventBusError
Event fired when any operation on the event bus fails.
KafkaMessageReader
Kafka-specific BusMessageReader implementation that can optionally perform manual commits and expose consumer lag metrics.
KafkaMessageWriter
Kafka-specific writer that extends the generic message writer with partition keys, headers and flush support.
KafkaMetadata
Kafka-specific metadata
MessageMetadata
Generic message metadata that works across all backends
MessageQueue
Channel receiver resource for background consumer -> main thread.
MessageWrapper
Unified message wrapper that provides direct access to message data along with its metadata.
ProcessedMessage
Pre-processed message with payload and metadata already converted for efficient reading.
ProvisionedTopology
Tracks the provisioned backend topologies so readers can validate configuration without touching backend internals. Only one backend of each type is expected to be active.
RedisMessageReader
Redis-specific BusMessageReader implementation that exposes manual acknowledgements.
RedisMessageWriter
Redis-specific writer that provides stream trimming and configuration-driven options.
SharedRuntime
Bevy resource wrapper for a shared Tokio runtime (Arc for cheap clone into async tasks)

Enums§

EventBusErrorType
Categories of errors that can occur in the event bus.
KafkaReaderError
Errors that can occur when working with the Kafka-specific reader.
KafkaWriterError
Errors emitted by the Kafka-specific writer when backend operations fail.
RedisReaderError
Errors that can occur when working with the Redis-specific reader.
RedisWriterError
Errors emitted by the Redis-specific writer when backend operations fail.

Constants§

DEFAULT_MAX_RETAINED_PER_TOPIC
Default upper bound on the number of messages retained per topic.

Traits§

BackendMetadata
Trait for backend-specific metadata extensions
BusMessageReader
Common capabilities shared by all bus message readers.
BusMessageWriter
Common interface shared by all outbound message writers.

Functions§

block_on
Block on a future using the shared runtime.
ensure_runtime
Ensure a SharedRuntime resource exists in the provided app.
runtime
Get a reference to the shared Tokio runtime (Arc inside OnceCell)

Type Aliases§

BusErrorCallback
Callback invoked when an error occurs.