Documentation ¶
Overview ¶
Package data -> this package is responsible for the data layer
Index ¶
- func CreateCapsuleProcessRecord(process CapsuleProcess) (string, int)
- func DeleteCapsuleProcessRecord(key string) string
- func GetJSONCapsuleProcesses() ([]byte, error)
- func GetStatusLabel(status Status) string
- func SaveCapsuleProcessRecords() error
- func SearchLastIndexOfProcessRecord(functionName, functionRevision string) int
- func SetCapsuleProcessRecord(process CapsuleProcess) string
- type CapsuleProcess
- func DuplicateProcessWithNewRevision(functionName, newFunctionRevision string, index int, process CapsuleProcess) CapsuleProcess
- func GetAllCapsuleProcessRecords() []CapsuleProcess
- func GetCapsuleProcessRecord(key string) (CapsuleProcess, error)
- func GetCapsuleProcessRecordsRelatedTo(functionName string) []CapsuleProcess
- type CapsuleTask
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateCapsuleProcessRecord ¶
func CreateCapsuleProcessRecord(process CapsuleProcess) (string, int)
CreateCapsuleProcessRecord creates a new CapsuleProcess record and returns its key.
process: a CapsuleProcess struct containing information about the process. string: the key of the newly created CapsuleProcess record.
func DeleteCapsuleProcessRecord ¶
DeleteCapsuleProcessRecord deletes a process record from the runningCapsules map given a key.
key: a string representing the key to delete from the map. returns: a string representing the deleted key.
func GetJSONCapsuleProcesses ¶
GetJSONCapsuleProcesses retrieves a JSON-encoded list of running capsule processes.
This function takes no parameters and returns a slice of bytes and an error.
func GetStatusLabel ¶
GetStatusLabel returns the status label for a given status.
status: a Status type representing the current status of the process. Returns a string representing the label for the current status.
func SaveCapsuleProcessRecords ¶
func SaveCapsuleProcessRecords() error
SaveCapsuleProcessRecords saves the runningCapsules map to a json file at the specified storage location. It returns an error if one occurs.
Return: error
func SearchLastIndexOfProcessRecord ¶
SearchLastIndexOfProcessRecord returns the last order number of the processes with the given function name and revision.
functionName: the name of the function to search for. functionRevision: the revision of the function to search for. int: the last order number of the processes found.
func SetCapsuleProcessRecord ¶
func SetCapsuleProcessRecord(process CapsuleProcess) string
SetCapsuleProcessRecord stores a CapsuleProcess for a given key in the runningCapsules map.
key: a string representing the key to store the CapsuleProcess. process: a CapsuleProcess to be stored in the runningCapsules map.
Types ¶
type CapsuleProcess ¶
type CapsuleProcess struct { Index int `json:"index"` FunctionName string `json:"functionName"` FunctionRevision string `json:"functionRevision"` FormerFunctionRevision string `json:"formerFunctionRevision"` HTTPPort string `json:"httpPort"` Description string `json:"description"` CurrentStatus Status `json:"currentStatus"` StatusDescription string `json:"statusDescription"` CreatedAt time.Time `json:"createdAt"` // record the time the event was requested StartedAt time.Time `json:"startedAt"` FinishedAt time.Time `json:"finishedAt"` CancelledAt time.Time `json:"cancelledAt"` FailedAt time.Time `json:"failedAt"` CheckedAt time.Time `json:"checkedAt"` Pid int `json:"pid"` Path string `json:"path"` Args []string `json:"args"` Env []string `json:"env"` Cmd *exec.Cmd `json:"-"` }
CapsuleProcess is a struct to describe a running Capsule process
func DuplicateProcessWithNewRevision ¶
func DuplicateProcessWithNewRevision(functionName, newFunctionRevision string, index int, process CapsuleProcess) CapsuleProcess
DuplicateProcessWithNewRevision creates a new record with the same process (PID) but with different revision.
It takes in the function name, new function revision, an index, and a CapsuleProcess object. It returns a CapsuleProcess object.
func GetAllCapsuleProcessRecords ¶
func GetAllCapsuleProcessRecords() []CapsuleProcess
GetAllCapsuleProcessRecords returns all the capsule process records.
None. []CapsuleProcess.
func GetCapsuleProcessRecord ¶
func GetCapsuleProcessRecord(key string) (CapsuleProcess, error)
GetCapsuleProcessRecord retrieves the CapsuleProcess associated with a given key.
key string: the key to look up in the runningCapsules map. CapsuleProcess: the CapsuleProcess associated with the given key, or an empty CapsuleProcess if the key is not found.
func GetCapsuleProcessRecordsRelatedTo ¶
func GetCapsuleProcessRecordsRelatedTo(functionName string) []CapsuleProcess
GetCapsuleProcessRecordsRelatedTo returns an array of CapsuleProcess records that are related to the given function name.
functionName: A string representing the name of the function to match. []CapsuleProcess: An array of CapsuleProcess records related to the given function name.
type CapsuleTask ¶
type CapsuleTask struct { FunctionName string `json:"name"` FunctionRevision string `json:"revision"` Description string `json:"description"` Path string `json:"path"` Args []string `json:"args"` Env []string `json:"env"` }
CapsuleTask is a struct with the parameters to start a Capsule process