Documentation ¶
Index ¶
- type Connection
- func (conn *Connection) Close() error
- func (conn *Connection) DeleteSession(id string) error
- func (conn *Connection) GetAllJobs() ([]Job, error)
- func (conn *Connection) GetJob(id int64) (*Job, error)
- func (conn *Connection) GetSession(id string) (*Session, error)
- func (conn *Connection) GetUserJobs(uid int64) ([]Job, error)
- func (conn *Connection) InsertJob(job *Job) error
- func (conn *Connection) InsertSession(sess *Session) error
- func (conn *Connection) UpdateJob(job *Job) error
- type Job
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection embeds a xorm.Engine and implements functions for interacting with the Tonic database backend.
func New ¶
func New(path string) (*Connection, error)
New returns a database connection for the sqlite db file at the given path. If it does not exist it is created.
func (*Connection) DeleteSession ¶
func (conn *Connection) DeleteSession(id string) error
DeleteSession removes the Session matching the given ID from the database.
func (*Connection) GetAllJobs ¶
func (conn *Connection) GetAllJobs() ([]Job, error)
GetAllJobs returns all Job entries in the database.
func (*Connection) GetJob ¶
func (conn *Connection) GetJob(id int64) (*Job, error)
GetJob retrieves a Job from the database given its ID.
func (*Connection) GetSession ¶
func (conn *Connection) GetSession(id string) (*Session, error)
GetSession retrieves a session from the database given its ID.
func (*Connection) GetUserJobs ¶
func (conn *Connection) GetUserJobs(uid int64) ([]Job, error)
GetUserJobs retrieves all the Jobs associated with a given UserID.
func (*Connection) InsertJob ¶
func (conn *Connection) InsertJob(job *Job) error
InsertJob inserts a new Job into the database. Upon successful return, the Job has a new unique ID.
func (*Connection) InsertSession ¶
func (conn *Connection) InsertSession(sess *Session) error
InsertSession inserts a new Session into the database. Upon successful return, the Job has a new unique ID.
func (*Connection) UpdateJob ¶
func (conn *Connection) UpdateJob(job *Job) error
UpdateJob updates an existing Job entry in the database.
type Job ¶
type Job struct { // Job ID (auto) ID int64 `xorm:"pk autoincr"` // ID of user who submitted the job UserID int64 // Name/label of the job Label string // Messages returned from finished job. This will be visible to the user // once the job is finished. Messages []string // Error message (if the job failed). Error string // Form values that created the job ValueMap map[string][]string // Time when the job was submitted to the queue SubmitTime time.Time // Time when the job finished (0 if ongoing) EndTime time.Time // mutex for locking sync.Mutex `xorm:"-"` }
Job holds all the information for a given Job.
func (*Job) IsFinished ¶
IsFinished returns true if the Job has finished (has an EndTime).
type Session ¶
type Session struct { // Session ID (stored in the cookie) ID string `xorm:"pk"` // App Token for user Token string // ID of the user who owns the session (maps to GIN user ID) UserID int64 // Time when the session was created (for expiration) Created time.Time }
Session holds all the information for a given user Session
func NewSession ¶
NewSession creates a new session for a user with the given token and a new unique ID.