Skip to main content

Crate drasi_source_grpc

Crate drasi_source_grpc 

Source
Expand description

gRPC Source Plugin for Drasi

This plugin exposes a gRPC endpoint for receiving data change events. External systems can stream events to Drasi using the gRPC protocol, which provides efficient binary serialization and bidirectional streaming support.

§Service Endpoints

The gRPC source implements the following service methods:

  • submit_event - Submit a single event (unary RPC)
  • stream_events - Stream multiple events (client streaming RPC)
  • request_bootstrap - Request initial data for bootstrapping (server streaming RPC)
  • health_check - Check service health (unary RPC)

§Protocol Buffer Format

Events are submitted using the SourceChange protobuf message. See the proto/drasi/v1/source.proto file for the full schema.

§Insert/Update

SourceChange {
    type: INSERT or UPDATE
    change: Element {
        node: Node {
            metadata: ElementMetadata { ... }
            properties: Struct { ... }
        }
    }
}

§Delete

SourceChange {
    type: DELETE
    change: Metadata {
        reference: ElementReference { ... }
        labels: ["Label1", "Label2"]
    }
}

§Configuration

FieldTypeDefaultDescription
hoststring"0.0.0.0"Host address to bind to
portu1650051Port to listen on
endpointstringNoneOptional custom endpoint path
timeout_msu645000Request timeout in milliseconds

§Example Configuration (YAML)

source_type: grpc
properties:
  host: "0.0.0.0"
  port: 50051

§Usage Example

use drasi_source_grpc::{GrpcSource, GrpcSourceConfig};
use std::sync::Arc;

let config = GrpcSourceConfig {
    host: "0.0.0.0".to_string(),
    port: 50051,
    endpoint: None,
    timeout_ms: 5000,
};

let source = Arc::new(GrpcSource::new("my-grpc-source", config)?);
drasi.add_source(source).await?;

§Client Example (using grpcurl)

grpcurl -plaintext -d '{"event": {...}}' localhost:50051 drasi.v1.SourceService/SubmitEvent

Re-exports§

pub use config::GrpcSourceConfig;

Modules§

config
Configuration types for gRPC source.
descriptor
gRPC source plugin descriptor and configuration DTOs.
proto

Structs§

GrpcSource
gRPC source that exposes a gRPC endpoint to receive SourceChangeEvents.
GrpcSourceBuilder
Builder for gRPC sources.