17 unstable releases (4 breaking)
new 0.5.0-rc.1 | Jan 3, 2025 |
---|---|
0.4.10 | Sep 30, 2024 |
0.4.5 | Jul 24, 2024 |
0.3.1 | Mar 25, 2024 |
#52 in HTTP server
721 downloads per month
Used in 2 crates
(via dsh_api)
390KB
7.5K
SLoC
dsh-sdk-platform-rs
NOTE
As this is a release candidate it may contain bugs and/or incomplete features and incorrect documentation and future updates may contain breaking changes.
Please report any issues you encounter.
Migration guide 0.4.X -> 0.5.X
See migration guide for more information on how to migrate from 0.4.X to 0.5.X.
Description
This library can be used to interact with the DSH Platform. It is intended to be used as a base for services that will be used to interact with DSH. Features include:
- Connect to DSH
- Fetch Kafka Properties and certificates
- Rest API Token Fetcher (to be used with dsh_rest_api_client)
- MQTT Token Fetcher
- Common functions
- Preconfigured RDKafka client config
- Preconfigured Reqwest client config (for schema store)
- Graceful shutdown
- Prometheus Metrics (web server and re-export of metrics crate)
- Dead Letter Queue (experimental)
Note
Rdkafka and thereby this library is dependent on CMAKE. Make sure it is installed in your environment and/or Dockerfile where you are compiling. See dockerfile for an example.
Usage
To use this SDK with the default features in your project, add the following to your Cargo.toml file:
[dependencies]
dsh_sdk = "0.5"
However, if you would like to use only specific features, you can specify them in your Cargo.toml file. For example, if you would like to use only the bootstrap feature, add the following to your Cargo.toml file:
[dependencies]
dsh_sdk = { version = "0.5", default-features = false, features = ["rdkafka"] }
rdkafka = { version = "0.37", features = ["cmake-buld", "ssl-vendored"] }
See feature flags for more information on the available features.
To use this SDK in your project
use dsh_sdk::DshKafkaConfig;
use rdkafka::consumer::{Consumer, StreamConsumer};
use rdkafka::ClientConfig;
fn main() -> Result<(), Box<dyn std::error::Error>>{
// get a rdkafka consumer config for example
let consumer: StreamConsumer = ClientConfig::new().dsh_consumer_config().create()?;
}
Connect to DSH
The SDK is compatible with running in a container on a DSH tenant, on DSH System Space, on a machine with Kafka Proxy/VPN or on a local machine to a local Kafka. See CONNECT_PROXY_VPN_LOCAL for more info.
Feature flags
See the migration guide for more information on the changes in feature flags since the v0.5.X update.
The following features are available in this library and can be enabled/disabled in your Cargo.toml file:
feature | default | Description |
---|---|---|
bootstrap |
✓ | Generate signed certificate and fetch datastreams info |
kafka |
✓ | Enable DshKafkaConfig trait and Config struct to connect to DSH |
rdkafka-config |
✓ | Enable DshKafkaConfig implementation for RDKafka |
protocol-token-fetcher |
✗ | Fetch tokens to use DSH Protocol adapters (MQTT and HTTP) |
management-api-token-fetcher |
✗ | Fetch tokens to use DSH Management API |
metrics |
✗ | Enable prometheus metrics including http server |
graceful-shutdown |
✗ | Tokio based gracefull shutdown handler |
dlq |
✗ | Dead Letter Queue implementation |
rest-token-fetcher |
✗ | Replaced by management-api-token-fetcher |
mqtt-token-fetcher |
✗ | Replaced by protocol-token-fetcher |
See api documentation for more information on how to use these features including.
Environment variables
The default RDKafka config can be overwritten by setting environment variables. See ENV_VARIABLES.md for more information.
Api doc
See the api documentation for more information on how to use this library.
Examples
See folder dsh_sdk/examples for simple examples on how to use the SDK.
Full service example
See folder example_dsh_service for a full service, including how to build the Rust project and post it to Harbor. See readme for more information.
Changelog
See CHANGELOG.md for all changes per version.
Contributing
See CONTRIBUTING.md for more information on how to contribute to this project.
License
See LICENSE for more information on the license for this project.
Security
See SECURITY.md for more information on the security policy for this project.
Copyright (c) Koninklijke KPN N.V.
Dependencies
~0.4–19MB
~297K SLoC