Endpoint
endpoint, region and test_credentials point the broker at a local stack; queue URLs the service returns are rebased onto the endpoint.
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.
On a broker built with from_config, endpoint and region replace the config's own, and the config supplies the rest.
A local stack returns queue URLs on a host of its own choosing, which may not resolve from the service.
The broker keeps the path of each URL and puts the configured endpoint in front of it, so a stack's host strategy changes nothing.
An endpoint from AWS_ENDPOINT_URL or from the config given to from_config is rebased the same way.
The generated AsyncAPI document reports the endpoint's host and port as the server.
A broker with no endpoint and a known region is reported by the regional host, such as sqs.eu-west-1.amazonaws.com.
Example
The service runs against LocalStack on port 4566.
- Macros
- Manual
/// The broker for a local stack at `endpoint`, such as `LocalStack` on port 4566. The stack checks
/// that a request is signed and ignores the key, so test credentials are enough.
fn broker(endpoint: &str) -> SqsBroker {
SqsBroker::new()
.endpoint(endpoint)
.region("us-east-1")
.test_credentials()
}
#[app]
fn app() -> impl App {
service(broker("http://localhost:4566"), "orders".to_owned())
}
/// The broker for a local stack at `endpoint`, such as `LocalStack` on port 4566. The stack checks
/// that a request is signed and ignores the key, so test credentials are enough.
fn broker(endpoint: &str) -> SqsBroker {
SqsBroker::new()
.endpoint(endpoint)
.region("us-east-1")
.test_credentials()
}
fn app() -> impl App {
service(broker("http://localhost:4566"), "orders".to_owned())
}