utils

package
v0.0.85 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStatusNotFound = errors.New("Not Found")
View Source
var ErrTaskAborted = errors.New("Aborted")

ErrTaskAborted error thrown when a taks is aborted

View Source
var (
	// XAuthTokenHeader is the name of the header supposed to contain the auth token
	XAuthTokenHeader = "X-Auth-Token"
)

Functions

func AreStringSliceElementsEqual added in v0.0.6

func AreStringSliceElementsEqual(s1 []string, s2 []string) bool

AreStringSliceElementsEqual check the same elements are in both slices but they can be in different order

func AreStringSlicesEqual added in v0.0.6

func AreStringSlicesEqual(s1 []string, s2 []string) bool

AreStringSlicesEqual check equality between two slices

func ChunkSlice

func ChunkSlice(s interface{}, chunkSize int) interface{}

ChunkSlice chunk a slice in smaller chunks of size chunkSize

func HTTPGetJSON

func HTTPGetJSON(url string, username string, password string, response interface{}) error

func IsStringInSlice

func IsStringInSlice(s string, slice []string) bool

IsStringInSlice check if string is in string slice

Types

type BytesBuffer

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

BytesBuffer represent bytes buffer as ReadCloser

func NewBytesBuffer

func NewBytesBuffer(p []byte) *BytesBuffer

NewBytesBuffer create a bytes buffer

func (*BytesBuffer) Close

func (bb *BytesBuffer) Close() error

Close the bytes buffer

func (*BytesBuffer) Read

func (bb *BytesBuffer) Read(p []byte) (n int, err error)

Read from the byte buffer

type HTTPClient

type HTTPClient struct {
	*http.Client

	CacheDir string
}

HTTPClient is an http client perofrming caching

func NewHTTPClient

func NewHTTPClient() *HTTPClient

NewHTTPClient create an http client

func (*HTTPClient) Do

func (hc *HTTPClient) Do(req *http.Request) (*http.Response, error)

Do perform the http request

type RecurrentTask

type RecurrentTask struct {
	RunAtStartup bool
	// contains filtered or unexported fields
}

RecurrentTask represent a recurrent task

func NewRecurrentTask

func NewRecurrentTask(interval time.Duration, callback func()) RecurrentTask

NewRecurrentTask create a recurrent task

func (*RecurrentTask) Start

func (rt *RecurrentTask) Start()

Start a recurrent task

func (*RecurrentTask) Stop

func (rt *RecurrentTask) Stop()

Stop the recurrent task

type Registry added in v0.0.66

type Registry[T comparable, U any] struct {
	// contains filtered or unexported fields
}

func NewRegistry added in v0.0.66

func NewRegistry[T comparable, U any]() *Registry[T, U]

func (*Registry[T, U]) Del added in v0.0.66

func (r *Registry[T, U]) Del(k T)

func (*Registry[T, U]) Get added in v0.0.66

func (r *Registry[T, U]) Get(k T) (U, bool)

func (*Registry[T, U]) Set added in v0.0.66

func (r *Registry[T, U]) Set(k T, v U)

type SynchronizedMap

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

func NewSynchronizedMap

func NewSynchronizedMap() *SynchronizedMap

func (*SynchronizedMap) Get

func (sm *SynchronizedMap) Get(key string) (interface{}, bool)

func (*SynchronizedMap) Set

func (sm *SynchronizedMap) Set(key string, value interface{})

type Task added in v0.0.18

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

Task is a representation of a task

type WorkerPool added in v0.0.18

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

WorkerPool a pool of workers able to perform multiple tasks in parallel

func NewWorkerPool added in v0.0.18

func NewWorkerPool(workers int) *WorkerPool

NewWorkerPool instantiate a new worker pool

func (*WorkerPool) Close added in v0.0.18

func (wp *WorkerPool) Close()

Close the worker pool

func (*WorkerPool) Exec added in v0.0.18

func (wp *WorkerPool) Exec(f func() error) chan error

Exec enqueues one task into the worker pool

Jump to

Keyboard shortcuts

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