postgres

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 13 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(connURL string) (drivers.Driver, error)

func WithInstance

func WithInstance(dbInstance *sql.DB) (drivers.Driver, error)

Types

type Mutex

type Mutex struct {
	// contains filtered or unexported fields
}

Mutex is similar to sync.Mutex, except usable by morph to lock the db.

Pick a unique name for each mutex your plugin requires.

A Mutex must not be copied after first use.

func NewMutex

func NewMutex(key string, driver drivers.Driver, logger drivers.Logger) (*Mutex, error)

NewMutex creates a mutex with the given key name.

returns error if key is empty.

func (*Mutex) Lock

func (m *Mutex) Lock(ctx context.Context) error

Lock locks m unless the context is canceled. If the mutex is already locked by any other instance, including the current one, the calling goroutine blocks until the mutex can be locked, or the context is canceled.

The mutex is locked only if a nil error is returned.

func (*Mutex) Unlock

func (m *Mutex) Unlock() error

Unlock unlocks m. It is a run-time error if m is not locked on entry to Unlock.

Just like sync.Mutex, a locked Lock is not associated with a particular goroutine or a process.

Jump to

Keyboard shortcuts

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