|
StripeKit 0.1.1
Stripe integration toolkit for C++
|
A de-duplication store that uses a SQLite database. More...
#include <SqliteWebhookDedupStore.h>
Public Member Functions | |
| SqliteWebhookDedupStore (std::string database_path) | |
| Opens or creates the database. | |
| ~SqliteWebhookDedupStore () override | |
| Closes the database and destroys the store. | |
| ClaimResult | claim (const ClaimRequest &request) override |
| Tries to reserve an event id for processing. | |
| bool | mark_processed (std::string_view event_id, std::chrono::system_clock::time_point processed_at) override |
| Records that an event has been fully handled. | |
| bool | release_claim (std::string_view event_id, std::chrono::system_clock::time_point claimed_at) override |
| Releases an unfinished claim after its handler has stopped. | |
| void | erase_expired (std::chrono::system_clock::time_point now, std::chrono::hours retention) override |
| Deletes records older than the retention period. | |
| Public Member Functions inherited from stripekit::WebhookDedupStore | |
| virtual | ~WebhookDedupStore ()=default |
| Destroys the store instance. | |
A de-duplication store that uses a SQLite database.
The sensible default for an application running on a single host: unlike InMemoryWebhookDedupStore it survives restarts, and it needs no database server. Applications running several instances should implement WebhookDedupStore against their shared database instead, since separate SQLite files cannot agree on which events are done.
Only available when StripeKit was built with SQLite support; check sqlite_dedup_store_is_available() if that is in doubt.
The store must outlive every handler that uses it. Safe to use from several threads.
Definition at line 43 of file SqliteWebhookDedupStore.h.
|
explicit |
Opens or creates the database.
Missing tables are created, so a fresh path just works.
| database_path | Path to the SQLite file. Its directory must exist and be writable, and the file must be on local storage; network filesystems do not give SQLite the locking it needs. |
| ConfigurationException | The database could not be opened or prepared, or this build has no SQLite support. |
|
override |
Closes the database and destroys the store.
|
overridevirtual |
Tries to reserve an event id for processing.
| request | The event id to reserve, and the timing rules to apply. |
Implements stripekit::WebhookDedupStore.
|
overridevirtual |
Records that an event has been fully handled.
| event_id | The event id that was handled. |
| processed_at | When it finished. |
Implements stripekit::WebhookDedupStore.
|
overridevirtual |
Releases an unfinished claim after its handler has stopped.
Delete only the unprocessed record whose claim time matches claimed_at, so an older attempt cannot release a newer worker's reservation.
| event_id | The event to allow another delivery to retry. |
| claimed_at | The successful ClaimRequest::now for this attempt. |
| StripeKitException | The store could not release the claim. |
Implements stripekit::WebhookDedupStore.
|
overridevirtual |
Deletes records older than the retention period.
| now | Current time. |
| retention | How long a record must be kept. Keep this longer than Stripe's retry window, which runs for several days. |
Implements stripekit::WebhookDedupStore.