Documentation
¶
Index ¶
Constants ¶
const ( EveryConnection = "*" OwnDatabase = "self" )
EveryConnection observes the statements of every connection but the context's own database, which is observed separately as OwnDatabase.
Variables ¶
This section is empty.
Functions ¶
func ObserveSQL ¶
ObserveSQL hands deliver every statement published for connection until release is called: EveryConnection for any connection but the context's own database, and OwnDatabase for that. deliver runs on the goroutine that ran the statement, so it must not block.
func ObservingSQL ¶
ObservingSQL reports whether anyone observes connection's statements, so a publisher can skip describing a statement nobody receives.
func PublishSQL ¶
func PublishSQL(statement Statement)
PublishSQL hands statement to the observers of its connection and, unless it ran on the context's own database, to those of every connection.
Types ¶
type Statement ¶
type Statement struct {
Connection string
Driver string
SQL string
Args []any
StartedAt time.Time
Duration time.Duration
// Rows is how many rows the statement returned, or -1 when unknown.
Rows int64
Error string
}
Statement is one SQL statement commons-db ran. Connection names the connection it ran on: OwnDatabase for the context's own database, and empty for a connection given without a name, such as by URL.