utils

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: PostgreSQL Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidIdentifier = errors.New(`valid IDs must be 1-63 characters long, contain only lower-cased letters and hyphens, start and end with a letter or number, and not contain two consecutive hyphens`)
View Source
var ErrTimedOut = errors.New("operation timed out")

Functions

func AnyQueue

func AnyQueue() workflow.Queue

func BuildOptionArgs

func BuildOptionArgs(options map[string]string) []string

func Clean

func Clean(s string) string

Clean removes all non-printing characters from the given string.

func ClonePointer

func ClonePointer[T any](v *T) *T

func FromPointer

func FromPointer[T comparable](v *T) T

FromPointer dereferences the input pointer if it's non-nil or returns the zero value for T if the pointer is nil.

func HostQueue

func HostQueue(hostID string) workflow.Queue

func ManagerQueue

func ManagerQueue() workflow.Queue

func NillablePointerTo

func NillablePointerTo[T comparable](v T) *T

NillablePointerTo returns a pointer to v if v is not the zero value of its type, otherwise it returns nil.

func PointerTo

func PointerTo[T any](v T) *T

func RandomString

func RandomString(length int) (string, error)

func Retry

func Retry(maxAttempts int, initialDelay time.Duration, f func() error) error

Retry retries the given function up to maxAttempts times with an exponential backoff starting at initialDelay.

func ValidateID

func ValidateID(value string) error

func WithTimeout

func WithTimeout(ctx context.Context, timeout time.Duration, f func(ctx context.Context) error) error

Types

type LineWriter

type LineWriter struct {
	// contains filtered or unexported fields
}

LineWriter is an io.Writer that buffers input until a newline is seen. When a newline is encountered, it calls the provided emit function with the line (without the newline).

func NewLineWriter

func NewLineWriter(emit func([]byte) error) *LineWriter

NewLineWriter creates a new LineWriter with the given emit function. The emit function is called whenever a full line is buffered (newline is removed).

func (*LineWriter) Close

func (w *LineWriter) Close() error

Close forces the buffered data to be emitted, even if no newline is present.

func (*LineWriter) Write

func (w *LineWriter) Write(p []byte) (n int, err error)

Write implements io.Writer. It buffers data until a newline is encountered.

Jump to

Keyboard shortcuts

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