Skip to main content

Shutdown

Shutdown closes the connection; a publisher or a seek handle taken earlier reports KinesisError::NotConnected instead of acting.

At shutdown the runtime stops the subscriptions first. Each shard reader then releases its lease, so another instance can take the shard at once instead of waiting for the lease to expire. A publish is one PutRecord call that returns when the service has stored the record, so the broker holds no queue to flush. Then the runtime shuts the broker down.

A publisher taken before the shutdown keeps pointing at the closed connection. KinesisBroker::publisher hands one out before the service starts, for code that publishes outside any handler. It shares the broker's connection, so it publishes once the service is up. After the shutdown a publish through it returns KinesisError::NotConnected, and never writes to a stream the service no longer reads. A seek handle kept past the shutdown answers the same way.

Example​

An admin endpoint beside the service publishes cancellations through a publisher taken from the broker.

use ruststream_kinesis::KinesisPublisher;
use ruststream_kinesis::prelude::*;

/// The service, and a publisher for the code beside it that publishes outside any handler, such
/// as an admin endpoint.
fn service(broker: KinesisBroker) -> (RustStream, KinesisPublisher) {
let admin = broker.publisher();
let app = RustStream::new(AppInfo::new("orders", "0.1.0")).with_broker(broker, |b| {
b.include(place);
});
(app, admin)
}