Expand description
Confluent Schema Registry-compatible REST service for Crabka.
Standalone binary; a Kafka client of a Crabka broker. State lives in the
_schemas compacted topic.
§Runtime configuration
use crabka_schema_registry::config::{RegistryConfig, SecurityConfig};
let config = RegistryConfig {
bootstrap: "localhost:9092".into(),
schemas_topic: "_schemas".into(),
schemas_topic_rf: 3,
client_id: "schema-registry-1".into(),
advertised_url: "http://schema-registry-1:8081".into(),
group_id: "schema-registry".into(),
leader_eligibility: true,
security: SecurityConfig::default(),
};
assert_eq!(config.schemas_topic, "_schemas");§Compatibility checks
use crabka_schema_registry::format::{self, SchemaType};
let prior = r#"{"type":"record","name":"Order","fields":[{"name":"id","type":"string"}]}"#;
let next = r#"{"type":"record","name":"Order","fields":[{"name":"id","type":"string"},{"name":"total","type":["null","double"],"default":null}]}"#;
assert!(format::check(SchemaType::Avro, next, prior, &[], &[]).is_ok());Modules§
- auth
- Authentication middleware: resolve a
crabka_security::Principalfrom each request (mTLS → Bearer → Basic → Anonymous) into request extensions;401on a bad credential or a missing one whenrequire_auth. Reusescrabka_securityvalidators; onlyBasicAuthStoreis local. Modelsgrpc-gateway/src/authz/auth_layer.rs. - authz
- Topic-ACL authorization for the registry REST surface.
- cli
- Clap-free CLI →
SecurityConfigassembly. - compat
- Compatibility engine: resolve the effective level, pick the version set, and
run the per-format directional check. Format-agnostic (delegates to
format::check); knows nothing about Avro/Protobuf/JSON internals. - config
- Runtime configuration for the registry service.
- election
- Schema Registry primary election (cp-exact
"sr"Kafka group). A node joins the group; the leader selects the primary and broadcasts it; every node publishes itsPrimaryStatefor the forwarding middleware. - error
- Confluent-compatible error model: numeric
error_code+ HTTP status, serialised as{"error_code":N,"message":"..."}with the vendor content-type. Serdes branch onerror_code, so the numbers are exact. - format
- Schema formats: parse, canonical storage form, and directional compatibility checks. Canonical form is the global-id deduplication key.
- kafkastore
- Kafka-backed schema store — reads/writes from the
_schemascompacted topic. - rest
- HTTP surface:
AppState+ the merged Confluent route table. - store
- In-memory authoritative registry state, rebuilt by replaying
_schemas. Pure data structure: no I/O. TheKafkaStorewraps it behind a lock and the write-serialisation gate (see kafkastore/mod.rs). Cloneable so the write path can decide id/version on a throwaway copy (the reader is the sole mutator of the live instance).