下面显示的是英文原文。
Endpoint
endpoint, region and test_credentials point the broker at a local stack such as LocalStack; each overrides one setting of the default chain.
endpoint replaces the AWS endpoint with an address such as http://localhost:4566, where LocalStack listens.
region sets the region every request is signed for.
test_credentials signs requests with a fixed dummy key: a local stack checks that a request is signed and ignores the key.
Each step overrides only its own setting, and the SDK's default chain resolves the rest.
The three steps apply to a broker built with new; a broker built with from_config takes all three from its config.
The generated AsyncAPI document reports the endpoint's host and port as the server.
A broker with no endpoint and a named region is reported as that region's Kinesis host, kinesis.<region>.amazonaws.com.
Example
The service runs against a local stack on port 4566.
- Macros
- Manual
/// The broker on the local stack at `endpoint`: the region is named, and the credentials are
/// dummies the stack accepts.
fn broker(endpoint: &str) -> KinesisBroker {
KinesisBroker::new()
.endpoint(endpoint)
.region("us-east-1")
.test_credentials()
}
#[ruststream::app]
fn app() -> impl App {
service(broker("http://localhost:4566"))
}
/// The broker on the local stack at `endpoint`: the region is named, and the credentials are
/// dummies the stack accepts.
fn broker(endpoint: &str) -> KinesisBroker {
KinesisBroker::new()
.endpoint(endpoint)
.region("us-east-1")
.test_credentials()
}
fn app() -> impl App {
service(broker("http://localhost:4566"))
}