| Crates.io | dsh_sdk |
| lib.rs | dsh_sdk |
| version | 0.7.1 |
| created_at | 2024-01-25 10:22:02.359068+00 |
| updated_at | 2025-07-18 12:48:52.652506+00 |
| description | SDK for KPN Data Services Hub |
| homepage | https://www.kpn.com/dsh |
| repository | https://github.com/kpn-dsh/dsh-sdk-platform-rs |
| max_upload_size | |
| id | 1113627 |
| size | 520,231 |
A Rust SDK to interact with the DSH Platform. This library provides convenient building blocks for services that need to connect to DSH Kafka, fetch tokens for various protocols, manage Prometheus metrics, and more.
If you are migrating from v0.4.X, please see the migration guide for details on breaking changes and how to update your code accordingly.
The dsh-sdk-platform-rs library offers:
DSH Kafka Connectivity
Certificates
Token Fetchers
dsh_rest_api_client.Schema Store Interaction
Common Utilities
To get started, add the following to your Cargo.toml:
[dependencies]
dsh_sdk = "0.7"
rdkafka = { version = "0.38", features = ["cmake-build", "ssl-vendored"] }
Note
By default, this SDK enables several features (see Feature Flags). If you do not need them all, you can disable default features to reduce compile times and dependencies.
use dsh_sdk::DshKafkaConfig; // Trait for applying DSH-specific configurations
use rdkafka::consumer::{Consumer, StreamConsumer};
use rdkafka::ClientConfig;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Configure an rdkafka consumer with DSH settings
let consumer: StreamConsumer = ClientConfig::new()
.set_dsh_consumer_config()
.create()?;
// Your application logic here
Ok(())
}
This SDK accommodates multiple deployment environments:
For more information, see the CONNECT_PROXY_VPN_LOCAL.md document.
Important
The feature flags have changed since thev0.5.Xupdate. Check the migration guide for details.
Below is an overview of the available features:
| feature | default | Description | Example |
|---|---|---|---|
bootstrap |
✓ | Certificate signing process and fetch datastreams properties | Kafka / Kafka Proxy |
kafka |
✓ | Enable DshKafkaConfig trait and Config struct to connect to DSH |
Kafka / Kafka Proxy |
rdkafka-config |
✓ | Enable DshKafkaConfig implementation for RDKafka |
Kafka / Kafka Proxy |
schema-store |
✗ | Interact with DSH Schema Store | Schema Store API |
protocol-token |
✗ | Fetch tokens to use DSH Protocol adapters (MQTT and HTTP) | Mqtt client / Mqtt websocket client / Token fetcher (full mediation) / Token fetcher (partial mediation) |
management-api-token-fetcher |
✗ | Fetch tokens to use DSH Management API | Token fetcher |
metrics |
✗ | Enable prometheus metrics including http server | Expose metrics |
graceful-shutdown |
✗ | Tokio based graceful shutdown handler | Graceful shutdown |
dlq |
✗ | Dead Letter Queue implementation | Full implementation example |
To pick only the features you need, disable the default features and enable specific ones. For instance, if you only want the Management API Token Fetcher:
[dependencies]
dsh_sdk = { version = "0.7", default-features = false, features = ["management-api-token-fetcher"] }
This SDK uses certain environment variables to configure connections to DSH. For a full list of supported variables and their usage, see ENV_VARIABLES.md.
You can find simple usage examples in the examples/ directory.
A more complete example is provided in the example_dsh_service/ directory, showcasing:
See the README in that directory for more information.
All changes per version are documented in CHANGELOG.md.
Contributions are welcome! For details on how to help improve this project, please see CONTRIBUTING.md.
This project is licensed under the Apache License 2.0.
For information about the security policy of this project, including how to report vulnerabilities, see SECURITY.md.
© Koninklijke KPN N.V.