Documentation ¶
Index ¶
- Constants
- Variables
- func BuildDeleteUri(resource string) string
- func BuildInsertUri(resource string) string
- func BuildQueryUri(resource string) string
- func BuildSql(r *sql.Request) string
- func BuildUpdateUri(resource string) string
- func ClientShutdown()
- func ClientStartup(db messaging.DatabaseUrl, credentials messaging.Credentials) error
- func IsStarted() bool
- func NewDeleteRequest(resource, template string, where []sql.Attr) *sql.Request
- func NewInsertRequest(resource, template string, values [][]any) *sql.Request
- func NewQueryRequest(resource, template string, where []sql.Attr) *sql.Request
- func NewQueryRequestFromValues(resource, template string, values map[string][]string) *sql.Request
- func NewUpdateRequest(resource, template string, attrs []sql.Attr, where []sql.Attr) *sql.Request
- func Ping[E runtime.ErrorHandler](ctx context.Context) (status *runtime.Status)
- func Scan[T Scanner[T]](rows Rows) ([]T, error)
- type CommandTag
- type FieldDescription
- type Rows
- type Scanner
- type Stats
Examples ¶
Constants ¶
View Source
const ( PostgresNID = "postgresql" PingUri = "urn:" + PostgresNID + ":" + sql.PingNSS StatUri = "urn:" + PostgresNID + ":" + sql.StatNSS )
Variables ¶
View Source
var (
Uri = pkgPath
)
Functions ¶
func BuildDeleteUri ¶
BuildDeleteUri - build an uri with the Delete NSS
func BuildInsertUri ¶
BuildInsertUri - build an uri with the Insert NSS
func BuildQueryUri ¶
BuildQueryUri - build an uri with the Query NSS
func BuildSql ¶
Example ¶
rsc := "access-log" t := "delete from access_log" req := NewDeleteRequest(rsc, t, nil) sql := BuildSql(req) fmt.Printf("test: Delete.BuildSql(%v) -> %v\n", t, sql) t = "update access_log" req = NewUpdateRequest(rsc, t, nil, nil) sql = BuildSql(req) fmt.Printf("test: Update.BuildSql(%v) -> %v\n", t, sql)
Output: test: Delete.BuildSql(delete from access_log) -> delete from access_log test: Update.BuildSql(update access_log) -> update access_log
func BuildUpdateUri ¶
BuildUpdateUri - build an uri with the Update NSS
func ClientShutdown ¶
func ClientShutdown()
func ClientStartup ¶
func ClientStartup(db messaging.DatabaseUrl, credentials messaging.Credentials) error
ClientStartup - entry point for creating the pooling client and verifying a connection can be acquired
Example ¶
db := messaging.DatabaseUrl{Url: ""} err := ClientStartup(db, nil) if err == nil { defer ClientShutdown() } fmt.Printf("test: ClientStartup() -> %v\n", err)
Output: test: ClientStartup() -> database URL is empty
func NewDeleteRequest ¶
func NewInsertRequest ¶
func NewQueryRequest ¶
func NewUpdateRequest ¶
func Ping ¶
Ping - templated function for pinging the database cluster
Example ¶
err := testStartup() if err != nil { fmt.Printf("test: testStartup() -> [error:%v]\n", err) } else { defer ClientShutdown() fmt.Printf("test: clientStartup() -> [started:%v]\n", IsStarted()) status := Ping[runtime.DebugError](nil) fmt.Printf("test: Ping(nil) -> %v\n", status) }
Output: test: clientStartup() -> [started:true] test: Ping(nil) -> OK
Types ¶
type CommandTag ¶
type CommandTag struct { Sql string RowsAffected int64 Insert bool Update bool Delete bool Select bool }
CommandTag - results from an Exec command
type FieldDescription ¶
type FieldDescription struct { Name string TableOID uint32 TableAttributeNumber uint16 DataTypeOID uint32 DataTypeSize int16 TypeModifier int32 Format int16 }
FieldDescription - data for defining the returned Query fields/columns
type Rows ¶
type Rows interface { // Close closes the rows, making the connection ready for use again. It is safe // to call Close after rows is already closed. Close() // Err returns any error that occurred while reading. Err() error // CommandTag returns the command tag from this query. It is only available after Rows is closed. CommandTag() CommandTag FieldDescriptions() []FieldDescription // Next prepares the next row for reading. It returns true if there is another // row and false if no more rows are available. It automatically closes rows // when all rows are read. Next() bool // Scan reads the values from the current row into dest values positionally. // dest can include pointers to core pgxsql, values implementing the Scanner // interface, and nil. nil will skip the value entirely. It is an error to // call Scan without first calling Next() and checking that it returned true. Scan(dest ...any) error // Values returns the decoded row values. As with Scan(), it is an error to // call Values without first calling Next() and checking that it returned // true. Values() ([]any, error) // RawValues returns the unparsed bytes of the row values. The returned data is only valid until the next Next // call or the Rows is closed. RawValues() [][]byte }
Rows - interface that proxies the postgresql Rows interface
type Stats ¶
Stats - pool statistics
func Stat ¶
Stat - templated function for retrieving runtime stats
Example ¶
err := testStartup() if err != nil { fmt.Printf("test: testStartup() -> [error:%v]\n", err) } else { defer ClientShutdown() fmt.Printf("test: clientStartup() -> [started:%v]\n", IsStarted()) stat, status := Stat[runtime.DebugError](nil) fmt.Printf("test: Stat(nil) -> [status:%v] [stat:%v]\n", status, stat != nil) }
Output: test: clientStartup() -> [started:true] test: Stat(nil) -> [status:OK] [stat:true]
Click to show internal directories.
Click to hide internal directories.