Documentation ¶
Overview ¶
Package worm contains worm.io Queue.
MIT License ¶
Copyright (c) 2016 Angel Del Castillo ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
- Constants
- func Close() error
- func Connect(connectURL, logDir string) error
- func CopyLog(w io.Writer, jobID string) error
- func DB() *sqlx.DB
- func MustRegister(workerName string, doer Doer)
- func Printf(w io.Writer, format string, args ...interface{})
- func Println(w io.Writer, args ...interface{})
- func Queue(workerName string, data []byte) (string, error)
- func Register(workerName string, doer Doer) error
- func Sched(workerName string, data []byte, cronformat string) (string, error)
- type Doer
- type Job
- type Worm
- func (h *Worm) Close() error
- func (h *Worm) CopyLog(w io.Writer, jobID string) error
- func (h *Worm) Detail(ID string) (*Job, error)
- func (h *Worm) MustRegister(workerName string, doer Doer)
- func (h *Worm) Queue(workerName string, data []byte) (string, error)
- func (h *Worm) Register(workerName string, doer Doer) error
- func (h *Worm) Sched(workerName string, data []byte, cronformat string) (string, error)
Constants ¶
const ( // StatusStart default job status. StatusStart = 1 // StatusOK success status code. StatusOK = 0 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Doer ¶
type Doer interface { // Name returns worker name. Name() string // Run executes the job and Worm writes the logOut to a file and state to // database. // If success state returned must be zero. Run(data []byte, logOutput io.Writer) (state int, err error) }
Doer interface. Your implementation must make sure that resources are only available there and reusable. For example you 'almost' everytime will need only one database connection for resources economy.
type Job ¶
type Job struct { ID string `db:"id" json:"id"` Worker string `db:"worker_name" json:"worker_name"` Status int `db:"status" json:"status"` Error string `db:"error" json:"error"` LogFile string `db:"log_file" json:"log_file"` Data string `db:"data" json:"data"` CreatedAt time.Time `db:"created_at" json:"created_at"` }
Job struct for database query.
type Worm ¶
Worm struct.
func (*Worm) MustRegister ¶
MustRegister register the worker interface for this worm.