Documentation
¶
Overview ¶
Package tmodel ...
Index ¶
- Constants
- func DeleteTaskFromDB(ctx context.Context, t *Task) error
- func GetAllTaskKeys(ctx context.Context) ([]string, error)
- func GetWriteConnection() *db.Conn
- func PersistTask(ctx context.Context, t *Task, db common.DbType) error
- func Transaction(ctx context.Context, key string, cb func(context.Context, string) error) error
- func ValidateTaskUserName(ctx context.Context, userName string) error
- type CompletedTask
- type Message
- type Oem
- type Payload
- type Task
- type Tick
Constants ¶
const ( // CompletedTaskIndex is a index name which is required for // to build index for completed tasks CompletedTaskIndex = "CompletedTaskIndex" //CompletedTaskTable is a Table name for Completed Task CompletedTaskTable = "CompletedTask" )
Variables ¶
This section is empty.
Functions ¶
func DeleteTaskFromDB ¶
DeleteTaskFromDB is to delete the task from db Takes:
t of type pointer to Task object
Returns:
err of type error On Success - return nil value On Failure - return non nill value
func GetAllTaskKeys ¶
GetAllTaskKeys will collect all task keys available in the DB Takes:
None
Returns:
Slice of type strings and error On Success - error is set to nil and returns slice of tasks On Failure - error is set to appropriate reason why it got failed and slice of task is set to nil
func GetWriteConnection ¶
GetWriteConnection returns write connection retrieved from the connection pool.
func PersistTask ¶
PersistTask is to store the task data in db Takes:
t pointer to Task to be stored. db of type common.DbType(int32)
func Transaction ¶
Transaction - is for performing atomic oprations using optimitic locking
Types ¶
type CompletedTask ¶
CompletedTask is used to build index for redis
type Message ¶
type Message struct { Message string `json:"Message"` MessageID string `json:"MessageId"` MessageArgs []string `json:"MessageArgs"` Oem Oem `json:"Oem"` RelatedProperties []string `json:"RelatedProperties"` Resolution string `json:"Resolution"` Severity string `json:"Severity"` }
Message Model
type Payload ¶
type Payload struct { HTTPHeaders map[string]string `json:"HttpHeaders"` HTTPOperation string `json:"HttpOperation"` JSONBody string `json:"JsonBody"` TargetURI string `json:"TargetUri"` }
Payload contain information detailing the HTTP and JSON payload information for executing the task. This object shall not be included in the response if the HidePayload property is set to True.
type Task ¶
type Task struct { ParentID string ChildTaskIDs []string ID string URI string UserName string Name string HidePayload bool Payload Payload /*The value of this property shall indicate the completion progress of the task, reported in percent of completion. If the task has not been started, the value shall be zero. */ PercentComplete int32 TaskMonitor string TaskState string TaskStatus string StatusCode int32 TaskResponse []byte Messages []*Message // Its there in the spec, how are we going to use it StartTime time.Time EndTime time.Time }
Task Model to be moved to dmtf
func GetTaskStatus ¶
GetTaskStatus is to retrieve the task data already present in db Takes:
taskID of type string contains the task ID of the task to be retrieved from the db db of type common.DbType(int32)
Returns:
err of type error On Success - return nil value On Failure - return non nill value t of type *Task implicitly valid only when error is nil
type Tick ¶
Tick struct is used to help the goroutines that process the task queue to communicate effectively Tick contains the following attributes
1. Ticker is of type Ticker in time package. it is used to acknowledge the function that process task queue that it is time to commit the current pipelined transaction to redis DB 2. M is of type Mutex in sync package. It ensures only one goroutine access the Commit and Executing flags at the same time. 3. Commit is a flag which is made true when ticker "ticks". when it is made true, "ProcessTaskQueue" commit the current pipeline to redis. 4. Executing is a flag which is made true when the "ProcessTaskQueue" function is invoked and made false when it is finished.
func (*Tick) ProcessTaskQueue ¶
ProcessTaskQueue dequeue the tasks details from queue and update DB using pipelined transaction the pipeline is committed when signal task is dequeued from the queue a signal task is enqueued by the caller once in a millisecond
ProcessTaskQueue takes the following keys as input:
1."queue" is a pointer to the channel which acts as the task queue 2."conn" is an instance of Conn struct in persistence manager library