Documentation
¶
Overview ¶
Package utils provides utility functions for the mailing list service.
Package utils provides utility functions for the mailing list service.
Package utils provides utility functions for the mailing list service.
Index ¶
- func FormatTimePtr(t *time.Time) *string
- func Int64PtrToUint64(val *int64) uint64
- func Int64PtrToUint64Ptr(val *int64) *uint64
- func NowRFC3339Ptr() *string
- func ParseTimestampPtr(timestamp *string) (*time.Time, error)
- func RetryWithExponentialBackoff(ctx context.Context, config RetryConfig, fn func() error) error
- func ValidateRFC3339(timestamp string) (time.Time, error)
- func ValidateRFC3339Ptr(timestamp *string) error
- type RetryConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatTimePtr ¶
FormatTimePtr formats a time.Time pointer as an RFC3339 string pointer. Returns nil if the input is nil.
func Int64PtrToUint64 ¶
Int64PtrToUint64 safely converts *int64 to uint64 for API calls. Returns 0 if the pointer is nil. This is commonly used when converting domain model IDs to API parameter types.
WARNING: Negative values will wrap around to large uint64 values. This function assumes the input represents a valid ID (non-negative). If you need validation, check for negative values before calling this function.
func Int64PtrToUint64Ptr ¶
Int64PtrToUint64Ptr safely converts *int64 to *uint64. Returns nil if the pointer is nil. This is used when optional pointer types need to be converted.
WARNING: Negative values will wrap around to large uint64 values. This function assumes the input represents a valid ID (non-negative). If you need validation, check for negative values before calling this function.
func NowRFC3339Ptr ¶
func NowRFC3339Ptr() *string
NowRFC3339Ptr returns the current time as an RFC3339 formatted string pointer.
func ParseTimestampPtr ¶
ParseTimestampPtr safely parses a timestamp pointer into a time.Time pointer. Returns nil if the input is nil or empty, or a pointer to the parsed time. Returns an error if parsing fails.
func RetryWithExponentialBackoff ¶
func RetryWithExponentialBackoff(ctx context.Context, config RetryConfig, fn func() error) error
RetryWithExponentialBackoff executes a function with exponential backoff retry logic The delay between retries follows the formula: baseDelay * 2^(attempt-1) The delay is capped at maxDelay to prevent excessively long waits
func ValidateRFC3339 ¶
ValidateRFC3339 validates that a timestamp string is in RFC3339 format. Returns the parsed time.Time and nil error if valid, or zero time and error if invalid.
func ValidateRFC3339Ptr ¶
ValidateRFC3339Ptr validates a timestamp pointer string is in RFC3339 format. Returns nil error if the pointer is nil or contains a valid timestamp.
Types ¶
type RetryConfig ¶
RetryConfig holds retry configuration for operations
func NewRetryConfig ¶
func NewRetryConfig(maxAttempts int, baseDelay, maxDelay time.Duration) RetryConfig
NewRetryConfig creates a RetryConfig with specified parameters