Expand description
OxiGeo Pub/Sub - Google Cloud Pub/Sub integration for OxiGeo.
This crate provides comprehensive support for Google Cloud Pub/Sub messaging, including publishing, subscribing, schema validation, and monitoring capabilities.
§Features
- Publisher: Async message publishing with batching and ordering keys
- Subscriber: Pull and push subscriptions with flow control
- Schema Support: Avro and Protobuf schema validation (feature-gated)
- Monitoring: Cloud Monitoring integration for metrics and observability
- Dead Letter Queues: Automatic handling of failed messages
- Flow Control: Intelligent message throttling and backpressure
§Example: Publishing Messages
use oxigeo_pubsub::{Publisher, PublisherConfig, Message};
async fn example() -> Result<(), Box<dyn std::error::Error>> {
let config = PublisherConfig::new("my-project", "my-topic")
.with_batching(true)
.with_batch_size(100);
let publisher = Publisher::new(config).await?;
let message = Message::new(b"Hello, Pub/Sub!".to_vec())
.with_attribute("source", "oxigeo")
.with_ordering_key("order-1");
let message_id = publisher.publish(message).await?;
println!("Published message: {}", message_id);
Ok(())
}§Example: Subscribing to Messages
use oxigeo_pubsub::{Subscriber, SubscriberConfig, HandlerResult};
async fn example() -> Result<(), Box<dyn std::error::Error>> {
let config = SubscriberConfig::new("my-project", "my-subscription")
.with_ack_deadline(30);
let subscriber = Subscriber::new(config).await?;
let _handle = subscriber.start(|message| {
println!("Received: {:?}", message.data);
HandlerResult::Ack
}).await?;
// Wait for shutdown signal...
subscriber.stop();
Ok(())
}§Feature Flags
std(default): Enable standard library supportasync(default): Enable async runtime supportpublisher(default): Enable publisher functionalitysubscriber(default): Enable subscriber functionalityschema: Enable schema supportavro: Enable Apache Avro schema supportprotobuf: Enable Protocol Buffers schema supportmonitoring: Enable Cloud Monitoring integrationbatching: Enable message batchingordering: Enable message orderingflow-control: Enable flow controldead-letter: Enable dead letter queue support
§Pure Rust Implementation
This crate uses Pure Rust implementations for all functionality:
google-cloud-pubsubfor Pub/Sub operationsgoogle-cloud-authfor authenticationgoogle-cloud-monitoringfor monitoring (optional)apache-avrofor Avro schema support (optional)prostfor Protocol Buffers support (optional)
§COOLJAPAN Policy Compliance
- ✅ Pure Rust (no C/Fortran dependencies)
- ✅ No
unwrap()usage (proper error handling) - ✅ Files under 2000 lines (modular design)
- ✅ Workspace dependencies
Re-exports§
pub use error::PubSubError;pub use error::Result;pub use schema::Schema;pub use schema::SchemaEncoding;pub use schema::SchemaRegistry;pub use schema::SchemaValidator;pub use schema::AvroSchema;pub use schema::ProtobufSchema;pub use monitoring::LatencyTracker;pub use monitoring::MetricPoint;pub use monitoring::MetricType;pub use monitoring::MetricValue;pub use monitoring::MetricsCollector;pub use monitoring::MetricsExporter;pub use monitoring::OperationTimer;pub use monitoring::PublisherMetrics;pub use monitoring::SubscriberMetrics;
Modules§
- error
- Error types for OxiGeo Pub/Sub operations.
- monitoring
- Monitoring and metrics for Google Cloud Pub/Sub.
- schema
- Schema support for Google Cloud Pub/Sub.
Constants§
- CRATE_
NAME - Crate name.
- VERSION
- Crate version.
Functions§
- crate_
name - Gets the crate name.
- version
- Gets the crate version.