Documentation
¶
Index ¶
- Variables
- func CleanupString(s string) string
- func DownloadWithProgress(sourceURL, destination string, callback func(progress float32), resume bool) error
- func ExtractCode(code string, re *regexp.Regexp) string
- func ExtractGoCode(code string) string
- func ExtractPythonCode(code string) string
- func ExtractPythonException(output string) string
- func FileExists(path string) bool
- func GenerateNestedSchemaForGET(v interface{}) *huma.Schema
- func GenerateNestedSchemaForGETString(v interface{}) string
- func GenerateNestedSchemaForPOSTPUT(v interface{}) *huma.Schema
- func GenerateNestedSchemaForPOSTPUTString(v interface{}) string
- func GenerateSchemaForGET(v interface{}) *huma.Schema
- func GenerateSchemaForGETString(v interface{}) string
- func GenerateSchemaForPOSTPUT(v interface{}) *huma.Schema
- func GenerateSchemaForPOSTPUTString(v interface{}) string
- func GetFileChecksum(filename string) (string, error)
- func GetFileSize(filename string) (int64, error)
- func GetJsonFieldName(v interface{}, fieldKey string) string
- func InitStructWithDefaults(v interface{})
- func IsPipe(file *os.File) bool
- func MergeJSONWithDefaults(defaultPtr interface{}, inputJSON string) (string, error)
- func NestedSchemaFromType(r huma.Registry, t reflect.Type) *huma.Schema
- func PrepareFilePath(filename string) error
- func SaveUploadedTempFile(file multipart.File, tempdir string, filename string) (string, error)
- func SetMutexDeadlockWarningDelay(seconds int)
- func SetMutexDebug(enabled bool)
- func StringToPrettyJSON(data string) string
- func StructToJSONString(v interface{}) (string, error)
- func TemplateToText(tmpl string) (string, error)
- func UnmarshalParquetFile(filePath string, v interface{}) error
- func ValidateJSONAgainstSchemaOnGet(paramsBytes []byte, params interface{}) error
- func ValidateJSONAgainstSchemaOnPost(paramsBytes []byte, params interface{}) error
- type DebugMutex
- type ExecResult
- type LineBuffer
- type ProgressTracker
- type SystemInfo
Constants ¶
This section is empty.
Variables ¶
var ( // MutexDebugEnabled enables mutex debugging features globally MutexDebugEnabled = false // WarnAfterLockDelaySeconds is the time to wait before warning about potential deadlocks WarnAfterLockDelaySeconds = 30 )
Functions ¶
func CleanupString ¶
func DownloadWithProgress ¶
func ExtractGoCode ¶
func ExtractPythonCode ¶
func ExtractPythonException ¶
func FileExists ¶
func GenerateNestedSchemaForGET ¶
GenerateNestedSchemaForGET generates a schema for a given struct excluding writeOnly fields. In contrast of GenerateSchemaForGET it serializes nested structures as well
func GenerateNestedSchemaForGETString ¶
func GenerateNestedSchemaForGETString(v interface{}) string
The same as GenerateNestedSchemaForGET but returns string representation of JSON
func GenerateNestedSchemaForPOSTPUT ¶
GenerateNestedSchemaForPOSTPUT generates a schema for a given struct excluding readOnly fields. In contrast of GenerateSchemaForPOSTPUT it serializes nested structures as well
func GenerateNestedSchemaForPOSTPUTString ¶
func GenerateNestedSchemaForPOSTPUTString(v interface{}) string
The same as GenerateNestedSchemaForPOSTPUT but returns string representation of JSON
func GenerateSchemaForGET ¶
GenerateSchemaForGET generates a schema for a given struct excluding writeOnly fields. It uses huma registry to possibly create references for nested structs. The schema that is returned can then be passed to `huma.Validate` to efficiently validate incoming requests.
func GenerateSchemaForGETString ¶
func GenerateSchemaForGETString(v interface{}) string
The same as GenerateSchemaForGET but returns string representation of JSON
func GenerateSchemaForPOSTPUT ¶
GenerateSchemaForPOSTPUT generates a schema for a given struct excluding readOnly fields. It uses huma registry to possibly create references for nested structs. The schema that is returned can then be passed to `huma.Validate` to efficiently validate incoming requests.
func GenerateSchemaForPOSTPUTString ¶
func GenerateSchemaForPOSTPUTString(v interface{}) string
The same as GenerateSchemaForPOSTPUT but returns string representation of JSON
func GetFileChecksum ¶
func GetFileSize ¶
func GetJsonFieldName ¶
func InitStructWithDefaults ¶
func InitStructWithDefaults(v interface{})
InitStructWithDefaults initializes a struct with default values from struct tags
func MergeJSONWithDefaults ¶
MergeJSONWithDefaults merges a given JSON string into the struct pointed to by defaultPtr, preserving existing default values for any missing fields. It also validates the merged JSON against the schema defined by defaultPtr using ValidateJSONAgainstSchemaOnPost. If inputJSON is empty, it returns the default struct as JSON. This function updates the value pointed to by defaultPtr with the merged result. It supports deep embedded structs and embedded structs within other embedded structs.
func NestedSchemaFromType ¶
Similar to numa.SchemaFromType, but instead of referncing nested structs they are serialized.
func PrepareFilePath ¶
func SaveUploadedTempFile ¶
SaveUploadedTempFile saves the uploaded file to a temporary location and returns the path If tempdir is provided, it uses that directory; otherwise uses the system default temp directory
func SetMutexDeadlockWarningDelay ¶
func SetMutexDeadlockWarningDelay(seconds int)
SetMutexDeadlockWarningDelay sets the delay before warning about potential deadlocks
func SetMutexDebug ¶
func SetMutexDebug(enabled bool)
SetMutexDebug enables or disables mutex debugging globally
func StringToPrettyJSON ¶
StringToPrettyJSON converts a string to a formatted JSON object
func StructToJSONString ¶
func TemplateToText ¶
func UnmarshalParquetFile ¶
func ValidateJSONAgainstSchemaOnGet ¶
ValidateJSONAgainstSchemaOnGet validates the JSON against the schema for GET requests
Types ¶
type DebugMutex ¶
DebugMutex is a drop-in replacement for sync.Mutex with debugging capabilities
func (*DebugMutex) GetOwner ¶
func (m *DebugMutex) GetOwner() int64
GetOwner returns the ID of the goroutine that currently holds the lock
func (*DebugMutex) IsLocked ¶
func (m *DebugMutex) IsLocked() bool
IsLocked returns whether the mutex is currently locked
func (*DebugMutex) Lock ¶
func (m *DebugMutex) Lock()
Lock acquires the mutex with debug capabilities
func (*DebugMutex) LockedAt ¶
func (m *DebugMutex) LockedAt() time.Time
LockedAt returns when the mutex was locked
func (*DebugMutex) TryLock ¶
func (m *DebugMutex) TryLock() bool
func (*DebugMutex) Unlock ¶
func (m *DebugMutex) Unlock()
Unlock releases the mutex with debug capabilities
type ExecResult ¶
type LineBuffer ¶
type LineBuffer struct {
// contains filtered or unexported fields
}
func NewLineBuffer ¶
func NewLineBuffer(ctx context.Context) *LineBuffer
NewLineBuffer creates a LineBuffer and starts a goroutine to scan written data.
func (*LineBuffer) Close ¶
func (lb *LineBuffer) Close() error
func (*LineBuffer) CloseAndGetLines ¶
func (lb *LineBuffer) CloseAndGetLines() []string
type ProgressTracker ¶
type ProgressTracker struct {
Total int64
Current int64
LastLog int
URL string
Dest string
Callback func(progress float32)
LastLogTime time.Time
ProgressThresholdMsec int64
// contains filtered or unexported fields
}
func (*ProgressTracker) Close ¶
func (pt *ProgressTracker) Close() error
ProgressTracker has to implement ReadCloser interface
func (*ProgressTracker) Read ¶
func (pt *ProgressTracker) Read(p []byte) (int, error)
ProgressTracker has to implement ReadCloser interface
func (*ProgressTracker) TrackProgress ¶
func (pt *ProgressTracker) TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) io.ReadCloser
type SystemInfo ¶
type SystemInfo struct {
ID uuid.UUID `json:"id" gorm:"primaryKey"`
CreatedAtMs int64 `json:"created_at" gorm:"index;type:bigint" doc:"unix timestamp in milliseconds"`
// OS information
OS struct {
Name string `json:"name" gorm:"column:os_name"`
Version string `json:"version" gorm:"column:os_version"`
Arch string `json:"arch" gorm:"column:os_arch"`
} `json:"os" gorm:"embedded"`
// CPU information
CPU struct {
Model string `json:"model" gorm:"column:cpu_model"`
NumCPUs int `json:"num_cpus" gorm:"column:cpu_num_cpus"`
Cores int `json:"cores" gorm:"column:cpu_cores"`
Frequency float64 `json:"frequency_mhz" gorm:"column:cpu_frequency_mhz"`
} `json:"cpu" gorm:"embedded"`
// GPU information
GPUs []struct {
Model string `json:"model" gorm:"column:gpu_model"`
Cores int `json:"cores" gorm:"column:gpu_cores"`
TotalMemoryMB float64 `json:"total_memory_mb" gorm:"column:gpu_total_memory_mb"`
UsedMemoryMB float64 `json:"used_memory_mb" gorm:"column:gpu_used_memory_mb"`
} `json:"gpus" gorm:"serializer:json"`
// Memory information
Memory struct {
Total uint64 `json:"total_bytes" gorm:"column:memory_total_bytes"`
Available uint64 `json:"available_bytes" gorm:"column:memory_available_bytes"`
Used uint64 `json:"used_bytes" gorm:"column:memory_used_bytes"`
UsedPerc float64 `json:"used_percent" gorm:"column:memory_used_percent"`
} `json:"memory" gorm:"embedded"`
// Host information
Host struct {
Hostname string `json:"hostname" gorm:"column:host_hostname"`
Uptime uint64 `json:"uptime_sec" gorm:"column:host_uptime_sec"`
} `json:"host" gorm:"embedded"`
// Battery information
Battery struct {
OnBattery bool `json:"on_battery" gorm:"column:on_battery"`
Percentage int `json:"percentage" gorm:"column:battery_percentage"`
} `json:"battery" gorm:"embedded"`
}
SystemInfo represents system information
func (*SystemInfo) FormatString ¶
func (si *SystemInfo) FormatString() string
FormatString returns a human-readable string representation of system information
func (*SystemInfo) ToMap ¶
func (si *SystemInfo) ToMap() map[string]string
ToMap converts system information to a map[string]string