Documentation
¶
Overview ¶
Package utils provides shared constants and utilities
Index ¶
- Constants
- func NullFloat64ToPtr(n sql.NullFloat64) *float64
- func NullInt32ToPtr(n sql.NullInt32) *int32
- func NullInt64ToPtr(n sql.NullInt64) *int64
- func NullStringToPtr(n sql.NullString) *string
- func NullStringToString(n sql.NullString) string
- func StringArrayToSlice(input pq.StringArray) []string
- type ResizableSemaphore
- func (s *ResizableSemaphore) AcquireWithWeight(ctx context.Context, weight float64, taskID int32) error
- func (s *ResizableSemaphore) Cap() float64
- func (s *ResizableSemaphore) Len() float64
- func (s *ResizableSemaphore) ReleaseTask(taskID int32)
- func (s *ResizableSemaphore) Resize(newSize float64)
- func (s *ResizableSemaphore) ResizeAll(newSize float64, updates map[int32]float64)
- func (s *ResizableSemaphore) ResizeTasks(updates map[int32]float64)
- func (s *ResizableSemaphore) Size() float64
Constants ¶
const MaxCommandLength = 1000
MaxCommandLength defines the maximum command length that can be executed directly without using script files. Commands longer than this require an explicit shell definition.
Variables ¶
This section is empty.
Functions ¶
func NullFloat64ToPtr ¶
func NullFloat64ToPtr(n sql.NullFloat64) *float64
func NullInt32ToPtr ¶
func NullInt64ToPtr ¶
func NullStringToPtr ¶
func NullStringToPtr(n sql.NullString) *string
func NullStringToString ¶
func NullStringToString(n sql.NullString) string
func StringArrayToSlice ¶
func StringArrayToSlice(input pq.StringArray) []string
StringArrayToSlice converts a pq.StringArray to a []string. Returns an empty []string if the input is nil.
Types ¶
type ResizableSemaphore ¶
type ResizableSemaphore struct {
// contains filtered or unexported fields
}
ResizableSemaphore manages dynamic concurrency limits and task weights.
func NewResizableSemaphore ¶
func NewResizableSemaphore(size float64) *ResizableSemaphore
NewResizableSemaphore initializes a semaphore with a given size.
func (*ResizableSemaphore) AcquireWithWeight ¶
func (*ResizableSemaphore) Cap ¶
func (s *ResizableSemaphore) Cap() float64
Cap returns the total capacity of the semaphore.
func (*ResizableSemaphore) Len ¶
func (s *ResizableSemaphore) Len() float64
Len returns the current available slots.
func (*ResizableSemaphore) ReleaseTask ¶
func (s *ResizableSemaphore) ReleaseTask(taskID int32)
ReleaseWeight returns the specific weight to the semaphore.
func (*ResizableSemaphore) Resize ¶
func (s *ResizableSemaphore) Resize(newSize float64)
Resize adjusts the semaphore size dynamically.
func (*ResizableSemaphore) ResizeAll ¶
func (s *ResizableSemaphore) ResizeAll(newSize float64, updates map[int32]float64)
ResizeTasks updates the weights of multiple tasks and adjusts the semaphore accordingly. This is useful for bulk updates or when multiple tasks are being resized at once.
func (*ResizableSemaphore) ResizeTasks ¶
func (s *ResizableSemaphore) ResizeTasks(updates map[int32]float64)
ResizeTasks updates the weights of multiple tasks and adjusts the semaphore accordingly. This is useful for bulk updates or when multiple tasks are being resized at once.
func (*ResizableSemaphore) Size ¶
func (s *ResizableSemaphore) Size() float64
return current size of semaphore