Documentation
¶
Index ¶
- Constants
- Variables
- func AppendToFile(filePath string, data []byte) error
- func Base64EncodeAndReplace(roomNumber string) string
- func CheckAndCreateDir(dirPath string) error
- func CleanString(origin string) string
- func ConcatMediaFile(ctx context.Context, fileList []string, fileName, storagePath string) error
- func CopyFile(src string, dstDir string) error
- func ExistDirectory(path string) error
- func ExtractPath(fullPath string) string
- func ExtractURLPath(urlStr string, config *ExtractPathConfig) (string, error)
- func FileExists(path string) (bool, error)
- func GenerateRtmpUrl(config *RtmpConfig) string
- func GenerateTencentRtmpUrl(config *RtmpConfig) string
- func GenerateUUID() string
- func GetAllQueuesUrl(domain, port, vhost string) string
- func GetExchangeBindingQueueUrl(domain, port, exchange, vhost string) string
- func GetFileSize(filePath string) (int64, error)
- func GetLogger() *zap.Logger
- func GetMediaParameters(media Media, resolutionLevel int) (int32, int32, int32, int32, int32, int32)
- func GetQueueInfoUrl(domain, port, queue, vhost string) string
- func GetRandomString(length int) (string, error)
- func GetRecordFilePath(config *RecordConfig) string
- func GetRecordFileUrl(domain, path string) string
- func GetResolution(ctx context.Context, filePath string) (*modelStruct.Resolution, string, string, error)
- func GetSecondTimeStamp() int64
- func GetTCTaskIDKey(prefix, appID, roomID, taskID string) string
- func GetTcRecordFilePath(config *RecordConfig) string
- func GetTimeStamp() int64
- func GetTimeString(format string) string
- func GetUTCTimeString(format string) string
- func GetVideoDuration(ctx context.Context, filePath string) (int64, string, error)
- func GetVideoDurationArgs(ctx context.Context, filePath string) []string
- func HasAudio(ctx context.Context, filePath string) (bool, string, string, error)
- func InitLogger(config LoggerConfig) error
- func JoinStrings(s ...string) string
- func MustGetLogger() *zap.Logger
- func ReadLines(filename string) ([]string, error)
- func RecoverPanic(ctx context.Context)
- func RemoveDir(dirPath string) error
- func RemoveFile(filePath string) error
- func Retry(req *RetryableRequest) error
- func RetryString(attempts int, sleep time.Duration, fn func() (interface{}, error)) (interface{}, error)
- func SafeGo(ctx context.Context, handler func(context.Context))
- func SafeGoWithParams(ctx context.Context, handler func(context.Context, ...interface{}), ...)
- func ScheduleDaily(targetHour, targetMinute, targetSecond int, task func())
- func ScheduleWeekly(targetWeekday time.Weekday, targetHour, targetMinute int, task func())
- func SendRequest(connectionRequest ConnectionRequest, request *modelStruct.RequestModel, ...)
- func SwitchToTime(timestamp string) (int64, error)
- func Sync() error
- func TruncateString(s string, maxLen int) string
- func WithTraceID(traceID string) *zap.Logger
- type CommandExecutor
- type ConnectionRequest
- type ExtractPathConfig
- type LoggerConfig
- type Media
- type RecordConfig
- type Resolution
- type RetryableRequest
- type RtmpConfig
- type SendConfig
- type TraceIDKey
Constants ¶
View Source
const ( HSetRecord = "hSetRecord" HGetAllRecord = "hGetAllRecord" HDeleteRecord = "hDeleteRecord" )
View Source
const LuaHDeleteRecord = `` /* 836-byte string literal not displayed */
View Source
const LuaHGetAllRecord = `` /* 851-byte string literal not displayed */
View Source
const LuaHSetRecord = `` /* 647-byte string literal not displayed */
Variables ¶
View Source
var (
Logger *zap.Logger
)
Functions ¶
func AppendToFile ¶
AppendToFile appendToFile 将数据追加到文件末尾
func Base64EncodeAndReplace ¶
func CheckAndCreateDir ¶
CheckAndCreateDir 检查指定的目录是否存在,如果不存在则创建它。
func CleanString ¶
func ConcatMediaFile ¶ added in v1.2.30
func ExistDirectory ¶
func ExtractPath ¶
func ExtractURLPath ¶
func ExtractURLPath(urlStr string, config *ExtractPathConfig) (string, error)
ExtractURLPath 从URL字符串中提取路径 参数:
urlStr - 要解析的URL字符串 config - 提取配置(传 nil 使用默认配置)
返回值:
string - 提取到的路径 error - 解析错误
func FileExists ¶
func GenerateRtmpUrl ¶
func GenerateRtmpUrl(config *RtmpConfig) string
func GenerateTencentRtmpUrl ¶
func GenerateTencentRtmpUrl(config *RtmpConfig) string
func GenerateUUID ¶
func GenerateUUID() string
func GetAllQueuesUrl ¶
func GetFileSize ¶
func GetMediaParameters ¶
func GetQueueInfoUrl ¶
func GetRandomString ¶
func GetRecordFilePath ¶
func GetRecordFilePath(config *RecordConfig) string
func GetRecordFileUrl ¶
func GetResolution ¶
func GetResolution(ctx context.Context, filePath string) (*modelStruct.Resolution, string, string, error)
func GetSecondTimeStamp ¶
func GetSecondTimeStamp() int64
func GetTCTaskIDKey ¶
func GetTcRecordFilePath ¶
func GetTcRecordFilePath(config *RecordConfig) string
func GetTimeStamp ¶
func GetTimeStamp() int64
func GetVideoDuration ¶
GetVideoDuration 获取视频时长
func GetVideoDurationArgs ¶
func RecoverPanic ¶ added in v1.2.67
RecoverPanic 捕获 panic 并记录日志
func RemoveFile ¶
func RetryString ¶
func RetryString(attempts int, sleep time.Duration, fn func() (interface{}, error)) (interface{}, error)
Retry 封装重试逻辑
func SafeGoWithParams ¶
func SafeGoWithParams(ctx context.Context, handler func(context.Context, ...interface{}), params ...interface{})
SafeGoWithParams 支持参数的安全协程
func ScheduleDaily ¶
func ScheduleDaily(targetHour, targetMinute, targetSecond int, task func())
ScheduleDaily 启动每日定时任务
func ScheduleWeekly ¶
scheduleWeekly 启动一个周期性任务,每周特定时间执行
func SendRequest ¶
func SendRequest(connectionRequest ConnectionRequest, request *modelStruct.RequestModel, sendConfig SendConfig)
func SwitchToTime ¶
func TruncateString ¶
Types ¶
type CommandExecutor ¶
type CommandExecutor struct {
Command string
Args []string
Stdout bytes.Buffer
Stderr bytes.Buffer
}
CommandExecutor 用于执行命令并捕获输出
func NewCommandExecutor ¶
func NewCommandExecutor() *CommandExecutor
NewCommandExecutor 创建一个新的 CommandExecutor 实例
func (*CommandExecutor) StderrOutput ¶
func (ce *CommandExecutor) StderrOutput() string
StderrOutput 获取标准错误输出
type ConnectionRequest ¶
type ConnectionRequest interface {
Request(request *modelStruct.RequestModel, response *modelStruct.ResponseModel, ctx context.Context) error
}
type ExtractPathConfig ¶
type ExtractPathConfig struct {
TrimLeadingSlash bool // 是否去除开头的斜杠
DecodePath bool // 是否解码百分比编码(如 %20 → 空格)
}
ExtractPathConfig 配置参数结构体
type LoggerConfig ¶
type Media ¶
type Media struct {
RecordFrameRate int32
RecordWidth int32
RecordHeight int32
RecordBitrate int32
Resolutions map[int]Resolution
}
func GetDefaultMedia ¶
func GetDefaultMedia() Media
type RecordConfig ¶
type RetryableRequest ¶
type RetryableRequest struct {
MaxRetries int // 最大重试次数(默认3)
OperationName string // 操作名称(用于日志)
Context context.Context // 上下文控制
ReqExecutor func() error // 请求执行函数
ErrChecker func() error // 错误检查函数
ErrCallback func(err error, index int) error // 错误回调函数(可选)
DelayStrategy func(int) time.Duration // 延时策略(可选)
}
type RtmpConfig ¶
type SendConfig ¶
type TraceIDKey ¶ added in v1.2.12
type TraceIDKey struct{}
Click to show internal directories.
Click to hide internal directories.