Documentation
¶
Overview ¶
Package postgresservice preserves the released service-adapter path. New code should import github.com/faustbrian/go-postgres/adapters/service.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidOptions identifies invalid adapter construction. // Deprecated: import github.com/faustbrian/go-postgres/adapters/service. ErrInvalidOptions = errors.New("invalid postgres service options") // Deprecated: import github.com/faustbrian/go-postgres/adapters/service. ErrUnavailable = errors.New("postgres service pool unavailable") )
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter preserves released type identity while delegating behavior to the canonical service adapter. Deprecated: import github.com/faustbrian/go-postgres/adapters/service.
func New
deprecated
New delegates to the canonical service adapter.
Deprecated: import github.com/faustbrian/go-postgres/adapters/service.
Example ¶
package main
import (
"context"
"fmt"
"github.com/faustbrian/go-postgres"
"github.com/faustbrian/go-postgres/postgresservice"
)
var _ postgresservice.Resource = (*postgres.Pool)(nil)
func main() {
pool := &resource{}
adapter, err := postgresservice.New(postgresservice.Options{
Name: "database",
Pool: pool,
TransferOwnership: true,
StartupPing: true,
})
if err != nil {
fmt.Println("adapter setup failed")
return
}
component := adapter.Component()
_ = component.Start(context.Background())
check := adapter.Readiness()
_ = check.Run(context.Background())
_ = component.Stop(context.Background())
fmt.Println(pool.pings, pool.closes)
}
Output: 2 1
func (*Adapter) Readiness ¶
func (adapter *Adapter) Readiness() service.ReadinessCheck
Readiness returns an opt-in dependency check for the active pool.
type Constructor ¶
Constructor acquires a pool whose ownership transfers after a successful return. Deprecated: import github.com/faustbrian/go-postgres/adapters/service.
type Options ¶
type Options struct {
// Name is the secret-safe component and readiness-check name.
Name string
// Construct acquires an adapter-owned pool during component startup.
Construct Constructor
// Pool supplies an existing pool.
Pool Resource
// TransferOwnership closes Pool during shutdown and failed startup.
TransferOwnership bool
// StartupPing validates the acquired pool before startup succeeds.
StartupPing bool
}
Options configure one PostgreSQL lifecycle adapter. Deprecated: import github.com/faustbrian/go-postgres/adapters/service.
type OptionsError ¶
OptionsError identifies a rejected option. Deprecated: import github.com/faustbrian/go-postgres/adapters/service.
func (*OptionsError) Error ¶
func (err *OptionsError) Error() string
Error returns a secret-safe construction diagnostic.
func (*OptionsError) Unwrap ¶
func (err *OptionsError) Unwrap() error
Unwrap exposes the stable option classification.
type Resource ¶
Resource is the released adapter resource contract. Deprecated: import github.com/faustbrian/go-postgres/adapters/service.
type StartupError ¶
StartupError preserves validation and cleanup failures. Deprecated: import github.com/faustbrian/go-postgres/adapters/service.
func (*StartupError) Error ¶
func (err *StartupError) Error() string
Error returns a secret-safe startup diagnostic.
func (*StartupError) Unwrap ¶
func (err *StartupError) Unwrap() []error
Unwrap preserves both failures for errors.Is and errors.As.