utils

package
v1.11.4 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultResources = &capsule.Resources{
	Requests: &capsule.ResourceList{
		CpuMillis:   200,
		MemoryBytes: 512_000_000,
	},
	Limits: &capsule.ResourceList{
		CpuMillis:   0,
		MemoryBytes: 0,
	},
}
View Source
var ErrFileIsTooLarge = errors.InvalidArgumentErrorf("file exceeds maximum file size")
View Source
var ErrInvalidUpdatedAt = errors.InvalidArgumentErrorf("invalid updated at timestamp")

Functions

func ErrorEqual added in v1.2.0

func ErrorEqual(t *testing.T, expected error, err error)

func FeedDefaultResources added in v1.1.3

func FeedDefaultResources(r *capsule.Resources)

func GetData

func GetData(stream interface {
	Receive() ([]byte, error)
}, maxSize int,
) ([]byte, error)

func GetExponentialBackoff

func GetExponentialBackoff(backoff float64, factor float64) time.Duration

func GetIdentifierFromIdentifier

func GetIdentifierFromIdentifier(userID uuid.UUID) (string, string)

func ImageExistsNatively added in v1.2.0

func ImageExistsNatively(ctx context.Context, dc *client.Client, image string) (bool, string, error)

func Retry

func Retry(amount int, dur time.Duration, x func() error) error

func UserIdentifier

func UserIdentifier(u *user.User) string

func UserName

func UserName(u *user.User) string

func ValiateConfigFilePath added in v1.1.3

func ValiateConfigFilePath(p string) error

valid path: 1. absolute 2. no trailing slash 3. no not escaped whitespace 4. no double slashes 5. no dots 6. non-empty

func ValidateEmail

func ValidateEmail(email string) error

func ValidatePassword

func ValidatePassword(password string) error

func ValidatePhone

func ValidatePhone(phone string) error

func ValidateURLPath added in v1.5.2

func ValidateURLPath(p string) error

ValidateURLPath validates the Path segment of an URL is correct https://datatracker.ietf.org/doc/html/rfc3986#section-3.3

Types

type DataReceive

type DataReceive func() ([]byte, error)

func (DataReceive) Receive

func (d DataReceive) Receive() ([]byte, error)

Jump to

Keyboard shortcuts

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