sqlobserve

package
v0.1.99 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 2 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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

func ObserveSQL(connection string, deliver func(Statement)) (release func())

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

func ObservingSQL(connection string) bool

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL