Help us shape the future of Go! Take the 2026 Go Developer Survey

utils

package
v0.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package utils provides shared constants and utilities

Index

Constants

View Source
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 NullInt32ToPtr(n sql.NullInt32) *int32

func NullInt64ToPtr

func NullInt64ToPtr(n sql.NullInt64) *int64

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 (s *ResizableSemaphore) AcquireWithWeight(ctx context.Context, weight float64, taskID int32) error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL