models

package
v0.0.0-...-52789aa Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2018 License: BSD-3-Clause Imports: 11 Imported by: 8

Documentation

Index

Constants

View Source
const (
	// Success task end success
	Success = iota
	// Failed task failed
	Failed
	// Expired task not performed within epsilon time frame
	Expired
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job struct {
	GUID    string                 `json:"guid"`
	UserID  string                 `json:"user_id"`
	At      int64                  `json:"at"`
	Epsilon int64                  `json:"epsilon"`
	URN     string                 `json:"URN"`
	Payload map[string]interface{} `json:"payload"`
}

Job is a task execution.

func (*Job) FromKafka

func (j *Job) FromKafka(msg *sarama.ConsumerMessage) error

FromKafka unserialize a Job from Kafka.

func (*Job) ToJSON

func (j *Job) ToJSON() ([]byte, error)

ToJSON serialize a Task as JSON.

func (*Job) ToKafka

func (j *Job) ToKafka() *sarama.ProducerMessage

ToKafka serialize a Job to Kafka.

type State

type State struct {
	ID       string `json:"id"`
	TaskGUID string `json:"taskGUID"`
	UserID   string `json:"userID"`
	At       int64  `json:"at"`
	DoneAt   int64  `json:"doneAt"`
	Duration int64  `json:"duration"`
	URN      string `json:"URN"`
	State    int64  `json:"state"`
}

State is a state of a task execution.

func (*State) FromJSON

func (s *State) FromJSON(in []byte) error

FromJSON unserialize a State from JSON.

func (*State) FromKafka

func (s *State) FromKafka(msg *sarama.ConsumerMessage) error

FromKafka unserialize a State from Kafka.

func (*State) ToJSON

func (s *State) ToJSON() ([]byte, error)

ToJSON serialize a State as JSON.

func (*State) ToKafka

func (s *State) ToKafka() *sarama.ProducerMessage

ToKafka serialize a State to Kafka.

type States

type States []State

States is a State array

type Task

type Task struct {
	GUID      string                 `json:"guid" sql:"guid,pk"`
	ID        string                 `json:"id" sql:"id"`
	UserID    string                 `json:"user_id"`
	Name      string                 `json:"name"`
	Schedule  string                 `json:"schedule"`
	URN       string                 `json:"URN"`
	Payload   map[string]interface{} `json:"payload" sql:",notnull"`
	CreatedAt time.Time              `json:"created_at"`
}

Task holds task attributes.

func (*Task) FromKafka

func (t *Task) FromKafka(msg *sarama.ConsumerMessage) error

FromKafka unserialize a Task from Kafka.

func (*Task) ToJSON

func (t *Task) ToJSON() ([]byte, error)

ToJSON serialize a Task as JSON.

func (*Task) ToKafka

func (t *Task) ToKafka() *sarama.ProducerMessage

ToKafka serialize a Task to Kafka.

type Tasks

type Tasks []Task

Tasks is a Task list

Jump to

Keyboard shortcuts

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