Documentation
¶
Overview ¶
Package txguard provides a utility class that keeps a database transaction active on a periodic basis.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Guard ¶
type Guard struct {
// contains filtered or unexported fields
}
Guard protects long-running database transactions in two ways. First, it will periodically execute a test statement on an existing database transaction to prevent an idle-in-session timeout from occurring. Secondly, it will roll the guarded transaction back if IsAlive is not called on a regular basis. The keepalive behavior will cease when either Commit or Rollback are called or if IsAlive is not called on a periodic basis.
func New ¶
New constructs a Guard around the given transaction. Once this function is called, the transaction should only ever be accessed via Guard.Use.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option can be passed to New.
func WithMaxMisses ¶
WithMaxMisses returns an Option that controls how many guard periods can elapse before the transaction is rolled back.
func WithPeriod ¶
WithPeriod controls how often the keepalive statement is executed and how often the Guard checks for calls to Guard.IsAlive.