Documentation
¶
Overview ¶
Package offline provides methods processing long-running tasks offline.
Index ¶
- Variables
- func NewJobId(ctx context.Context) (int64, error)
- func ProcessJob(ctx context.Context, opts *ProcessJobOptions) error
- func RegisterDatabase(ctx context.Context, scheme string, init_func DatabaseInitializationFunc) error
- func RegisterQueue(ctx context.Context, scheme string, init_func QueueInitializationFunc) error
- func Schemes() []string
- type Database
- type DatabaseInitializationFunc
- type DocstoreDatabase
- func (db *DocstoreDatabase) AddJob(ctx context.Context, job *Job) error
- func (db *DocstoreDatabase) Close(ctx context.Context) error
- func (db *DocstoreDatabase) GetJob(ctx context.Context, id int64) (*Job, error)
- func (db *DocstoreDatabase) ListJobs(ctx context.Context, cb ListJobsCallback) error
- func (db *DocstoreDatabase) PruneJobs(ctx context.Context, status Status, lastmodified int64) error
- func (db *DocstoreDatabase) RemoveJob(ctx context.Context, job *Job) error
- func (db *DocstoreDatabase) UpdateJob(ctx context.Context, job *Job) error
- type Job
- type JobStatusResponse
- type ListJobsCallback
- type NullQueue
- type ProcessJobCallbackFunc
- type ProcessJobOptions
- type PubSubQueue
- type Queue
- type QueueInitializationFunc
- type SlogQueue
- type Status
- type SyncMapDatabase
- func (db *SyncMapDatabase) AddJob(ctx context.Context, job *Job) error
- func (db *SyncMapDatabase) Close(ctx context.Context) error
- func (db *SyncMapDatabase) GetJob(ctx context.Context, job_id int64) (*Job, error)
- func (db *SyncMapDatabase) ListJobs(ctx context.Context, list_cb ListJobsCallback) error
- func (db *SyncMapDatabase) PruneJobs(ctx context.Context, status Status, lastmodified int64) error
- func (db *SyncMapDatabase) RemoveJob(ctx context.Context, job *Job) error
- func (db *SyncMapDatabase) UpdateJob(ctx context.Context, job *Job) error
Constants ¶
This section is empty.
Variables ¶
var SNOWFLAKE_NODE_ID = int64(575)
Functions ¶
func ProcessJob ¶ added in v0.0.3
func ProcessJob(ctx context.Context, opts *ProcessJobOptions) error
func RegisterDatabase ¶
func RegisterDatabase(ctx context.Context, scheme string, init_func DatabaseInitializationFunc) error
RegisterDatabase registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `Database` instances by the `NewDatabase` method.
func RegisterQueue ¶
func RegisterQueue(ctx context.Context, scheme string, init_func QueueInitializationFunc) error
RegisterQueue registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `Queue` instances by the `NewQueue` method.
Types ¶
type Database ¶
type Database interface {
// AddJob adds a `Job` instance to the database.
AddJob(context.Context, *Job) error
// Retrieve a specific `Job` instance from the database using its unique identifier.
GetJob(context.Context, int64) (*Job, error)
// Update a specific `Job` instance in the database.
UpdateJob(context.Context, *Job) error
// Remove a specific `Job` instance from the database.
RemoveJob(context.Context, *Job) error
// Prune zero or more `Job` instances matching a specific `Status` type and created date from the database.
PruneJobs(context.Context, Status, int64) error
// List all of the `Jobs` in the database.
ListJobs(context.Context, ListJobsCallback) error
// Close closes any underlying database connections
Close(context.Context) error
}
type Database is an interface for storing and retrieving `Job` instance for future processing. Importantly the interface does not define any logic for how or when jobs are processed.
func NewDatabase ¶
NewDatabase returns a new `Database` instance configured by 'uri'. The value of 'uri' is parsed as a `url.URL` and its scheme is used as the key for a corresponding `DatabaseInitializationFunc` function used to instantiate the new `Database`. It is assumed that the scheme (and initialization function) have been registered by the `RegisterDatabase` method.
func NewDocstoreDatabase ¶ added in v0.3.2
type DatabaseInitializationFunc ¶
DatabaseInitializationFunc is a function defined by individual database package and used to create an instance of that database
type DocstoreDatabase ¶ added in v0.3.2
type DocstoreDatabase struct {
Database
// contains filtered or unexported fields
}
func (*DocstoreDatabase) AddJob ¶ added in v0.3.2
func (db *DocstoreDatabase) AddJob(ctx context.Context, job *Job) error
func (*DocstoreDatabase) Close ¶ added in v0.3.2
func (db *DocstoreDatabase) Close(ctx context.Context) error
func (*DocstoreDatabase) ListJobs ¶ added in v0.3.2
func (db *DocstoreDatabase) ListJobs(ctx context.Context, cb ListJobsCallback) error
type Job ¶
type Job struct {
Id int64 `json:"id"`
Type string `json:"type"`
Status Status `json:"status"`
Creator string `json:"creator"`
Created int64 `json:"created"`
LastModified int64 `json:"lastmodified"`
Instructions string `json:"instructions"`
Results string `json:"results,omitempty"`
Error string `json:"error,omitempty"`
}
func ScheduleJob ¶ added in v0.0.8
func (*Job) AsStatusResponse ¶
func (job *Job) AsStatusResponse() *JobStatusResponse
type JobStatusResponse ¶
type ListJobsCallback ¶
type ListJobsCallback is a function type for custom processing of jobs.
type ProcessJobCallbackFunc ¶ added in v0.0.3
type ProcessJobOptions ¶ added in v0.0.3
type ProcessJobOptions struct {
Database Database
Callback ProcessJobCallbackFunc
JobId int64
}
type PubSubQueue ¶ added in v0.3.2
type PubSubQueue struct {
Queue
// contains filtered or unexported fields
}
func (*PubSubQueue) ScheduleJob ¶ added in v0.3.2
func (q *PubSubQueue) ScheduleJob(ctx context.Context, job_id int64) error
type Queue ¶
func NewPubSubQueue ¶ added in v0.3.2
func NewQueue ¶
NewQueue returns a new `Queue` instance configured by 'uri'. The value of 'uri' is parsed as a `url.URL` and its scheme is used as the key for a corresponding `QueueInitializationFunc` function used to instantiate the new `Queue`. It is assumed that the scheme (and initialization function) have been registered by the `RegisterQueue` method.
type QueueInitializationFunc ¶
QueueInitializationFunc is a function defined by individual queue package and used to create an instance of that queue
type SyncMapDatabase ¶
type SyncMapDatabase struct {
Database
// contains filtered or unexported fields
}
SyncMapDatabase implements the `Database` interface storing and retrieving jobs from an internal `sync.Map` instance.
func (*SyncMapDatabase) AddJob ¶
func (db *SyncMapDatabase) AddJob(ctx context.Context, job *Job) error
AddJob() stores 'job' in 'db'.
func (*SyncMapDatabase) Close ¶ added in v0.0.11
func (db *SyncMapDatabase) Close(ctx context.Context) error
func (*SyncMapDatabase) GetJob ¶
GetJob() returns a `Job` instance identified by 'job_id' from 'db'.
func (*SyncMapDatabase) ListJobs ¶
func (db *SyncMapDatabase) ListJobs(ctx context.Context, list_cb ListJobsCallback) error
ListJobs() iterates through all the jobs in 'db' passing each to 'list_cb'.
func (*SyncMapDatabase) PruneJobs ¶
PruneJobs() removed jobs in 'db' whose status matches 'status' and whose last modified time is less that 'lastmodified'.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
app
|
|
|
cmd
|
|
|
add-job
command
|
|
|
create-dynamodb-tables
command
|
|
|
get-job
command
|
|
|
job-server
command
|
|
|
remove-job
command
|
|
|
schedule-job
command
|
|
|
api
Package api provides methods for creating API-related HTTP handlers
|
Package api provides methods for creating API-related HTTP handlers |