Documentation
¶
Index ¶
- Constants
- func CloseConnection(connection Connection) error
- func Default() ctx.ServicePackage
- func IsErrNotFound(err error) bool
- func SessionContextReturning[T any](context context.Context, connection Connection, ...) (T, error)
- func SessionContextStream[T any](ctx context.Context, connection Connection, fetchSize int, ...) channels.StreamingChan[T]
- func SessionContextTxReturning[T any](context context.Context, connection Connection, ...) (T, error)
- func SessionReturning[T any](connection Connection, sessionFn func(session *Session) (T, error)) (T, error)
- func SessionStream[T any](connection Connection, fetchSize int, selectFn func(session *gorm.DB) *gorm.DB) channels.StreamingChan[T]
- func SessionTxReturning[T any](connection Connection, txFn func(session *Session) (T, error)) (T, error)
- func TxReturning[T any](session *Session, txFn func(session *Session) (T, error)) (T, error)
- type Connection
- type Paginator
- type Session
Constants ¶
View Source
const DefaultFetchSize = 1000
Variables ¶
This section is empty.
Functions ¶
func CloseConnection ¶ added in v0.6.0
func CloseConnection(connection Connection) error
CloseConnection closes a manually owned built-in connection. Container-managed connections invoke the same idempotent operation automatically during shutdown and disposal. Close calls may be repeated or concurrent. Manual Init and close phases remain serialized; operational calls may overlap a completed-generation restart and observe either inactive or fresh state.
func Default ¶
func Default() ctx.ServicePackage
func IsErrNotFound ¶
func SessionContextReturning ¶
func SessionContextStream ¶ added in v0.3.2
func SessionContextStream[T any](ctx context.Context, connection Connection, fetchSize int, selectFn func(session *gorm.DB) *gorm.DB) channels.StreamingChan[T]
SessionContextStream streams paginated query results with one shared context for pool work, queries, page delivery, and terminal completion. Cancel ctx before abandoning the output.
func SessionReturning ¶
func SessionReturning[T any](connection Connection, sessionFn func(session *Session) (T, error)) (T, error)
func SessionStream ¶ added in v0.3.2
func SessionStream[T any](connection Connection, fetchSize int, selectFn func(session *gorm.DB) *gorm.DB) channels.StreamingChan[T]
func SessionTxReturning ¶
func SessionTxReturning[T any](connection Connection, txFn func(session *Session) (T, error)) (T, error)
Types ¶
type Connection ¶
type Connection interface {
Init() error
AutoMigrate(models ...any)
Session(session func(session *Session) error) error
SessionContext(context context.Context, session func(session *Session) error) error
Stats() (sql.DBStats, error)
Check() error
Health() health.ServiceHealth
}
func NewConnection ¶
func NewConnection(name string, configPrefix string, isDefault bool, isCritical bool) Connection
Click to show internal directories.
Click to hide internal directories.