Documentation ¶
Index ¶
- Variables
- func InitDb(dbGorp *DbGorp) error
- func WorkParallel(db *DbGorp, tasks []func(worker *DbWorker), returnResults bool, ...) (results []interface{}, err error)
- type DbCallbackImplied
- type DbGeneric
- type DbGorp
- func (dbGorp *DbGorp) Begin() (txn *Transaction, err error)
- func (dbGorp *DbGorp) Builder() sq.StatementBuilderType
- func (dbGorp *DbGorp) CloneDb(open bool) (newDb *DbGorp, err error)
- func (dbGorp *DbGorp) Close() (err error)
- func (dbGorp *DbGorp) Delete(i ...interface{}) (int64, error)
- func (dbGorp *DbGorp) ExecInsert(builder sq.InsertBuilder) (r sql.Result, err error)
- func (dbGorp *DbGorp) ExecUpdate(builder sq.UpdateBuilder) (r sql.Result, err error)
- func (dbGorp *DbGorp) Get(i interface{}, keys ...interface{}) (interface{}, error)
- func (dbGorp *DbGorp) GetMap() DbGeneric
- func (dbGorp *DbGorp) InitDb(open bool) (err error)
- func (dbGorp *DbGorp) Insert(list ...interface{}) error
- func (dbGorp *DbGorp) OpenDb() (err error)
- func (dbGorp *DbGorp) Schema() (result string)
- func (dbGorp *DbGorp) Select(i interface{}, builder sq.SelectBuilder) (l []interface{}, err error)
- func (dbGorp *DbGorp) SelectInt(builder sq.SelectBuilder) (i int64, err error)
- func (dbGorp *DbGorp) SelectOne(i interface{}, builder sq.SelectBuilder) (err error)
- func (dbGorp *DbGorp) SetDbInit(dbInitFn func(dbMap *DbGorp) error) (err error)
- func (dbGorp *DbGorp) TraceOff()
- func (dbGorp *DbGorp) TraceOn(log logger.MultiLogger)
- func (dbGorp *DbGorp) Update(list ...interface{}) (int64, error)
- type DbInfo
- type DbReadable
- type DbWorkInfo
- type DbWorker
- type DbWorkerContainer
- type DbWriteable
- type SharedWorker
- type Transaction
- func (txn *Transaction) Builder() sq.StatementBuilderType
- func (txn *Transaction) Commit() (err error)
- func (txn *Transaction) Delete(i ...interface{}) (int64, error)
- func (txn *Transaction) ExecInsert(builder sq.InsertBuilder) (r sql.Result, err error)
- func (txn *Transaction) ExecUpdate(builder sq.UpdateBuilder) (r sql.Result, err error)
- func (txn *Transaction) Get(i interface{}, keys ...interface{}) (interface{}, error)
- func (txn *Transaction) GetMap() DbGeneric
- func (txn *Transaction) Insert(list ...interface{}) error
- func (txn *Transaction) Rollback() (err error)
- func (txn *Transaction) Schema() (result string)
- func (txn *Transaction) Select(i interface{}, builder sq.SelectBuilder) (l []interface{}, err error)
- func (txn *Transaction) SelectInt(builder sq.SelectBuilder) (i int64, err error)
- func (txn *Transaction) SelectOne(i interface{}, builder sq.SelectBuilder) (err error)
- func (txn *Transaction) Update(list ...interface{}) (int64, error)
- type WorkerPhase
Constants ¶
This section is empty.
Variables ¶
var ( // The database map to use to populate data. Db = &DbGorp{} )
Functions ¶
func WorkParallel ¶
func WorkParallel(db *DbGorp, tasks []func(worker *DbWorker), returnResults bool, maxNumWorkers int, timeouts int) (results []interface{}, err error)
Creates a container to run the group of workers (up to a max of maxNumWorkers), does not return to all workers are completed) If returnResults is true then the task MUST write to the DbWorker.OutputChannel once for every task.
Types ¶
type DbCallbackImplied ¶
type DbCallbackImplied struct { StatusFn func(phase WorkerPhase, worker *DbWorker) WorkFn func(value interface{}, worker *DbWorker) }
func (*DbCallbackImplied) Status ¶
func (dbCallback *DbCallbackImplied) Status(phase WorkerPhase, worker *DbWorker)
Call the status function if available.
func (*DbCallbackImplied) Work ¶
func (dbCallback *DbCallbackImplied) Work(value interface{}, worker *DbWorker)
Calls the work function.
type DbGeneric ¶
type DbGeneric interface { Select(i interface{}, query string, args ...interface{}) ([]interface{}, error) Exec(query string, args ...interface{}) (sql.Result, error) Insert(list ...interface{}) error Update(list ...interface{}) (int64, error) Delete(i ...interface{}) (int64, error) SelectOne(holder interface{}, query string, args ...interface{}) error }
type DbGorp ¶
type DbGorp struct { Map *gorp.DbMap // The Sql statement builder to use to build select statements SqlStatementBuilder sq.StatementBuilderType // Database connection information Info *DbInfo // contains filtered or unexported fields }
DB Gorp.
func (*DbGorp) Begin ¶
func (dbGorp *DbGorp) Begin() (txn *Transaction, err error)
Close the database connection.
func (*DbGorp) Builder ¶
func (dbGorp *DbGorp) Builder() sq.StatementBuilderType
func (*DbGorp) ExecInsert ¶
func (*DbGorp) ExecUpdate ¶
func (*DbGorp) Select ¶
func (dbGorp *DbGorp) Select(i interface{}, builder sq.SelectBuilder) (l []interface{}, err error)
func (*DbGorp) SelectInt ¶
func (dbGorp *DbGorp) SelectInt(builder sq.SelectBuilder) (i int64, err error)
func (*DbGorp) SelectOne ¶
func (dbGorp *DbGorp) SelectOne(i interface{}, builder sq.SelectBuilder) (err error)
func (*DbGorp) SetDbInit ¶
Used to specify the init function to call when database is initialized Calls the init function immediately.
func (*DbGorp) TraceOn ¶
func (dbGorp *DbGorp) TraceOn(log logger.MultiLogger)
type DbReadable ¶
type DbReadable interface { Builder() sq.StatementBuilderType Get(i interface{}, keys ...interface{}) (interface{}, error) Select(i interface{}, builder sq.SelectBuilder) (l []interface{}, err error) SelectOne(i interface{}, builder sq.SelectBuilder) (err error) SelectInt(builder sq.SelectBuilder) (i int64, err error) GetMap() DbGeneric Schema() string }
type DbWorkInfo ¶
type DbWorkInfo interface { Status(phase WorkerPhase, worker *DbWorker) Work(value interface{}, worker *DbWorker) }
func MakeCallback ¶
func MakeCallback(status func(phase WorkerPhase, worker *DbWorker), work func(value interface{}, worker *DbWorker)) DbWorkInfo
A function to return an object that is a valid DbCallback.
type DbWorkerContainer ¶
type DbWorkerContainer struct { Workers []*DbWorker NumWorkers int LongWorkTimeout int64 StartWorkTimeout int64 Db *DbGorp // contains filtered or unexported fields }
The worker container.
func NewDbWorker ¶
func NewDbWorker(db *DbGorp, workInfo DbWorkInfo, numWorkers int) (container *DbWorkerContainer)
This creates a DbWorkerContainer with the number of working threads already started. Each working thread has their own database instance running.
func (*DbWorkerContainer) Close ¶
func (container *DbWorkerContainer) Close(timeouts int) (totalWork int, err error)
func (*DbWorkerContainer) Start ¶
func (container *DbWorkerContainer) Start() (err error)
type DbWriteable ¶
type SharedWorker ¶
type SharedWorker struct { // contains filtered or unexported fields }
type Transaction ¶
type Transaction struct { Map *gorpa.Transaction // contains filtered or unexported fields }
This is a small wrapped around gorp.Transaction so you can make use of the builder statements as well.
func (*Transaction) Builder ¶
func (txn *Transaction) Builder() sq.StatementBuilderType
func (*Transaction) Commit ¶
func (txn *Transaction) Commit() (err error)
func (*Transaction) Delete ¶
func (txn *Transaction) Delete(i ...interface{}) (int64, error)
func (*Transaction) ExecInsert ¶
func (txn *Transaction) ExecInsert(builder sq.InsertBuilder) (r sql.Result, err error)
func (*Transaction) ExecUpdate ¶
func (txn *Transaction) ExecUpdate(builder sq.UpdateBuilder) (r sql.Result, err error)
func (*Transaction) Get ¶
func (txn *Transaction) Get(i interface{}, keys ...interface{}) (interface{}, error)
func (*Transaction) GetMap ¶
func (txn *Transaction) GetMap() DbGeneric
func (*Transaction) Insert ¶
func (txn *Transaction) Insert(list ...interface{}) error
func (*Transaction) Rollback ¶
func (txn *Transaction) Rollback() (err error)
func (*Transaction) Schema ¶
func (txn *Transaction) Schema() (result string)
func (*Transaction) Select ¶
func (txn *Transaction) Select(i interface{}, builder sq.SelectBuilder) (l []interface{}, err error)
func (*Transaction) SelectInt ¶
func (txn *Transaction) SelectInt(builder sq.SelectBuilder) (i int64, err error)
func (*Transaction) SelectOne ¶
func (txn *Transaction) SelectOne(i interface{}, builder sq.SelectBuilder) (err error)
func (*Transaction) Update ¶
func (txn *Transaction) Update(list ...interface{}) (int64, error)
type WorkerPhase ¶
type WorkerPhase int
const ( Start WorkerPhase = iota Stop StartJob EndJob JobLongrunning )