Skip to content

Conversation

@benjamin-stacks
Copy link

This is another PR I'm splitting out of #6762 since this commit is very self-contained.


The ability to have the event dispatcher not use the database was only used during tests; in actual production, there is always a DB.

Not having to support the DB-less use is going to make it a lot cleaner to use the DB as a (required) queue (see #6543).

This commit also makes the method names and order of operations a little less confusing -- we had send_payload(), send_payload_directly(), send_payload_given_db_path() (ok that one was my fault), and send_payload_with_bytes().

Now we have this instead:

dispatch_to_observer()
-> get_payload_bytes()
-> save_to_db()
-> make_http_request_and_delete_from_db()
   -> make_http_request()
   -> delete_from_db()

Reviewing notes

I've tried to keep the order of the functions in such a way that the diff has as little noise as possible, at least when you hide whitespace, which I strongly suggest).

This ability was only used during tests; in actual production, there is
always a DB.

Not having to support the DB-less use is going to make it a lot cleaner
to use the DB as a queue (see stacks-network#6543).

This commit also makes the method names and order of operations a little
less confusing -- we had `send_payload()`, `send_payload_directly()`,
`send_payload_given_db_path()` (ok that one was my fault),
and `send_payload_with_bytes()`.

Now we have this instead:

```
dispatch_to_observer()
-> get_payload_bytes()
-> save_to_db()
-> make_http_request_and_delete_from_db()
   -> make_http_request()
   -> delete_from_db()
```
DbError(stacks::util_lib::db::Error),
}

impl fmt::Display for EventDispatcherError {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hstove Pointed me to thiserror which can cut down on a bunch of the boilerplate here. I'll make that change as part of #6762 instead of in this PR.

Copy link
Contributor

@hstove-stacks hstove-stacks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@benjamin-stacks benjamin-stacks added this pull request to the merge queue Jan 9, 2026
Merged via the queue into stacks-network:develop with commit 4f535d8 Jan 9, 2026
1234 of 1240 checks passed
@benjamin-stacks benjamin-stacks deleted the refactor/no-db-less-event-dispatch branch January 9, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants