utils

package
v0.0.0-...-3875a57 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExponentialBackoff

func ExponentialBackoff(n uint, maximun_backoff float64) time.Duration

Exponential backoff algorithm

This algorithm calculates the wait time between retries based on the number of retries and a maximum backoff time.

The formula is:

wait_time = min(2^n + random_number_milliseconds, maximum_backoff)

where: n is the number of retries random_number_milliseconds is a random number between 0 and 50000 maximum_backoff is the maximum backoff time in milliseconds

func GetNextPageURL

func GetNextPageURL(linkHeader string) string

Helper function to get the next page URL from the "Link" header

Example of "Link" header: <https://api.github.com/repositories/1/commits?page=2>; rel="next", <https://api.github.com/repositories/1/commits?page=3>; rel="last"

func Paigenation

func Paigenation(pageStr, sizeStr string) (int, int)

Paigenation parses the page and size query parameters and returns the size and offset values.

If the page or size is not provided or invalid, it uses the default values (page=1, size=10).

func ValidateDate

func ValidateDate(date string) string

ValidateDate validates the date string and returns a valid RFC3339 date string.

If the date string is empty, it returns an empty string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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