Skip to main content

Crate oxigeo_pubsub

Crate oxigeo_pubsub 

Source
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 support
  • async (default): Enable async runtime support
  • publisher (default): Enable publisher functionality
  • subscriber (default): Enable subscriber functionality
  • schema: Enable schema support
  • avro: Enable Apache Avro schema support
  • protobuf: Enable Protocol Buffers schema support
  • monitoring: Enable Cloud Monitoring integration
  • batching: Enable message batching
  • ordering: Enable message ordering
  • flow-control: Enable flow control
  • dead-letter: Enable dead letter queue support

§Pure Rust Implementation

This crate uses Pure Rust implementations for all functionality:

  • google-cloud-pubsub for Pub/Sub operations
  • google-cloud-auth for authentication
  • google-cloud-monitoring for monitoring (optional)
  • apache-avro for Avro schema support (optional)
  • prost for 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.