Documentation
¶
Index ¶
- Constants
- func ExecuteHookPipeline(manager *HookProcessManager, scripts []HookScript, initialData interface{}, ...) (json.RawMessage, error)
- func ValidateHookScript(scriptFullCommand string, hookType string) error
- type DeleteHookData
- type DownloadHookData
- type DownloadHookDataAction
- type HookFileType
- type HookProcessManager
- type HookScript
- type HookScriptConfig
- type ManagedHookProcess
- type RecordingHookData
- type RecordingHookTask
- type ResumableUploadHookData
- type ResumableUploadHookType
- type ResumableUploadOutputType
- type RoomEndHookData
- type UploadHookData
Constants ¶
const ( // ProcessStateHealthy indicates the process is running and available. ProcessStateHealthy int32 = 0 // ProcessStateRecovering indicates the process has been found to be unhealthy and is being recovered. ProcessStateRecovering int32 = 1 )
const HookCommandHttpRequest = "http-request"
Variables ¶
This section is empty.
Functions ¶
func ExecuteHookPipeline ¶
func ExecuteHookPipeline(manager *HookProcessManager, scripts []HookScript, initialData interface{}, timeout time.Duration, log *logrus.Entry) (json.RawMessage, error)
ExecuteHookPipeline runs a series of scripts using the HookProcessManager. The manager will decide whether to use a long-lived process or a one-shot command.
func ValidateHookScript ¶
Types ¶
type DeleteHookData ¶
type DeleteHookData struct {
HookFileType HookFileType `json:"hook_file_type"`
InputPath string `json:"input_path"` // Path/URL of the file in remote storage to be deleted.
RoomId string `json:"room_id,omitempty"`
RoomSid string `json:"room_sid,omitempty"`
GroupId string `json:"group_id,omitempty"` // Unique identifier for the download operation (single file or file group)
// Fields below are typically set by the script as output, or can be passed along in a chain.
Error string `json:"error,omitempty"` // Error message from the script.
Msg string `json:"msg,omitempty"` // General message from the script.
}
DeleteHookData is used for the delete hook pipeline. It serves as both input to the script (from the server) and output from the script (back to the server). In a script chain, subsequent scripts receive the modified data from the previous script.
type DownloadHookData ¶
type DownloadHookData struct {
HookFileType HookFileType `json:"hook_file_type"`
InputPath string `json:"input_path"` // Path/URL of the file in remote storage to be downloaded.
RoomId string `json:"room_id,omitempty"`
RoomSid string `json:"room_sid,omitempty"`
GroupId string `json:"group_id,omitempty"` // Unique identifier for the download operation (single file or file group)
// Fields below are typically set by the script as output, or can be passed along in a chain.
Error string `json:"error,omitempty"` // Error message from the script.
Action DownloadHookDataAction `json:"action,omitempty"` // e.g., "serve_local" or "redirect".
RedirectUrl string `json:"redirect_url,omitempty"` // URL to redirect for download.
OutputPath string `json:"output_path,omitempty"` // Local path where the file was downloaded.
MimeType string `json:"mime_type,omitempty"`
}
DownloadHookData is used for the download pipeline. It serves as both input to the script (from the server) and output from the script (back to the server). In a script chain, subsequent scripts receive the modified data from the previous script.
type DownloadHookDataAction ¶
type DownloadHookDataAction string
const ( DownloadHookDataActionServeLocal DownloadHookDataAction = "serve_local" DownloadHookDataActionRedirect DownloadHookDataAction = "redirect" )
type HookFileType ¶
type HookFileType string
const ( HookFileTypeArtifact HookFileType = "artifact" HookFileTypeRecording HookFileType = "recording" HookFileTypeRecordingMetadata HookFileType = "recording-metadata" HookFileTypeRoomFile HookFileType = "room-file" HookFileTypeWhiteboardConvertedImgs HookFileType = "whiteboard-converted-imgs" // HookFileTypeFileGroup is used for operations where GroupId identifies a logical group of files. // whose contents are to be uploaded into the remote file group identified by GroupId. HookFileTypeFileGroup HookFileType = "file-group" )
type HookProcessManager ¶
type HookProcessManager struct {
// contains filtered or unexported fields
}
HookProcessManager manages all the long-lived hook processes.
func NewHookProcessManager ¶
func NewHookProcessManager(ctx context.Context, log *logrus.Entry) *HookProcessManager
NewHookProcessManager creates a new manager. The provided context should be the main application context to manage the lifecycle of the hook processes.
func (*HookProcessManager) StartHookProcesses ¶
func (h *HookProcessManager) StartHookProcesses(scriptsWithPoolSize map[string]int) error
StartHookProcesses starts pools of long-lived processes for each unique script. It is protected by a sync.Once to ensure it only runs once.
type HookScript ¶
HookScript defines a single script with its properties.
type HookScriptConfig ¶
type HookScriptConfig struct {
PoolSize int `yaml:"pool_size"`
Scripts []HookScript `yaml:"scripts"`
HookTimeout time.Duration `yaml:"hook_timeout"`
}
HookScriptConfig defines the configuration for a specific hook category.
type ManagedHookProcess ¶
type ManagedHookProcess struct {
// contains filtered or unexported fields
}
ManagedHookProcess holds the state for a true long-lived hook script.
type RecordingHookData ¶
type RecordingHookData struct {
Task RecordingHookTask `json:"task,omitempty"` // e.g., "single", "merge".
RecordingID string `json:"recording_id"`
RoomTableID int64 `json:"room_table_id"`
RoomID string `json:"room_id"`
RoomSID string `json:"room_sid"`
RecorderID string `json:"recorder_id"`
FileName string `json:"file_name,omitempty"` // Original or expected file name
FileSize float32 `json:"file_size,omitempty"`
// Input paths for the script. Can be local file paths or remote storage URLs.
InputPath string `json:"input_path,omitempty"` // Primary input path for single file tasks.
InputPaths []string `json:"input_paths,omitempty"` // Input paths for merge tasks.
// Fields below are typically set by the script as output, or can be passed along in a chain.
Error string `json:"error,omitempty"` // Error message from the script.
OutputPath string `json:"output_path,omitempty"` // Path/URL of the result after script execution.
ShouldCleanup bool `json:"should_cleanup,omitempty"` // Flag for post-transcoding scripts to clean up dir.
SourceForCleanup string `json:"source_for_cleanup,omitempty"` // Original file path to clean up after transcoding.
}
RecordingHookData defines the JSON payload passed to and from external scripts for recorder operations. It serves as both input to the script (from the recorder) and output from the script (back to the recorder). In a script chain, subsequent scripts receive the modified data from the previous script.
type RecordingHookTask ¶
type RecordingHookTask string
const ( RecordingHookTaskSingle RecordingHookTask = "single" RecordingHookTaskMerge RecordingHookTask = "merge" )
type ResumableUploadHookData ¶
type ResumableUploadHookData struct {
Type ResumableUploadHookType `json:"type"`
RoomSid string `json:"room_sid"`
RoomId string `json:"room_id"`
UserId string `json:"user_id"`
FileType string `json:"file_type,omitempty"`
// Present for "part-upload"
InputPath string `json:"input_path,omitempty"` // Path to the temporary local chunk file
// Identifiers, always present
ResumableIdentifier string `json:"resumable_identifier"`
ResumableFilename string `json:"resumable_filename,omitempty"`
// Present for "part-check" and "part-upload"
ResumableChunkNumber int `json:"resumable_chunk_number,omitempty"`
// Present for "merge"
ResumableTotalChunks int32 `json:"resumable_total_chunks,omitempty"`
ResumableCurrentChunkSize int64 `json:"resumable_current_chunk_size,omitempty"`
ResumableTotalSize int64 `json:"resumable_total_size,omitempty"`
// --- Fields set by the script as output ---
Error string `json:"error,omitempty"`
OutputResponseType ResumableUploadOutputType `json:"output_response_type,omitempty"`
// OutputPath should return Final URL/path of the merged file. The format should be roomSid/other parts
// for example: roomSid/fileName or in case converted images dir roomSid/FileId/page_1.png ...
OutputPath string `json:"output_path,omitempty"`
FileMimeType string `json:"file_mime_type,omitempty"`
FileExtension string `json:"file_extension,omitempty"`
}
ResumableUploadHookData is used for the resumable upload pipeline.
type ResumableUploadHookType ¶
type ResumableUploadHookType string
ResumableUploadHookType defines the stage of the resumable upload.
const ( ResumableUploadHookTypeCheck ResumableUploadHookType = "part-check" ResumableUploadHookTypeUpload ResumableUploadHookType = "part-upload" ResumableUploadHookTypeMerge ResumableUploadHookType = "merge" )
type ResumableUploadOutputType ¶
type ResumableUploadOutputType string
ResumableUploadOutputType defines the response type from the script.
const ( ResumableUploadOutputTypePartExists ResumableUploadOutputType = "part_exists" ResumableUploadOutputTypePartNotExists ResumableUploadOutputType = "part_not_exists" ResumableUploadOutputTypePartUploaded ResumableUploadOutputType = "part_uploaded" ResumableUploadOutputTypeMergeSuccess ResumableUploadOutputType = "merge_success" )
type RoomEndHookData ¶
type UploadHookData ¶
type UploadHookData struct {
HookFileType HookFileType `json:"hook_file_type"`
RoomId string `json:"room_id"`
RoomSid string `json:"room_sid"`
RoomTableId uint64 `json:"room_table_id,omitempty"`
FileId string `json:"file_id,omitempty"`
GroupId string `json:"group_id,omitempty"` // Unique identifier for the upload operation (single file or file group)
InputPath string `json:"input_path"` // Path to the file on the local system to be uploaded.
InputDirectoryPath string `json:"input_directory_path,omitempty"`
// Fields below are typically set by the script as output, or can be passed along in a chain.
Error string `json:"error,omitempty"` // Error message from the script.
OutputPath string `json:"output_path,omitempty"` // Path/URL where the file was uploaded (e.g., S3 URL).
}
UploadHookData is used for the upload pipeline. It serves as both input to the script (from the server) and output from the script (back to the server). In a script chain, subsequent scripts receive the modified data from the previous script.