internal

package
v5.1.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: Apache-2.0, MIT Imports: 10 Imported by: 0

Documentation

Overview

Package internal is none of your business

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RetryWithBackoff

func RetryWithBackoff(
	fn func() error,
	retryFor time.Duration,
) error

RetryWithBackoff calls the provided function repeatedly until it succeeds or until the retry duration is up.

Types

type FileLock

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

FileLock provides a file lock mechanism based on flock.

func NewFileLock

func NewFileLock(path string, verbose bool) (*FileLock, error)

NewFileLock creates a new instance of FileLock.

func (*FileLock) Acquire

func (f *FileLock) Acquire() error

Acquire tries to acquire a file lock. It is possible for multiple goroutines within the same process to acquire the same lock, so acquireLock is not thread safe in that sense, but protects access across different processes.

func (*FileLock) Release

func (f *FileLock) Release() error

Release unlocks the file lock.

type HTTPError

type HTTPError struct {
	Body       string
	StatusCode int
}

HTTPError is an error from performing an HTTP request.

func (HTTPError) Error

func (h HTTPError) Error() string

type JobProcessor

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

JobProcessor runs jobs with a set number of workers.

func NewJobProcessor

func NewJobProcessor(ctx context.Context, workers int) *JobProcessor

NewJobProcessor inits a new JobProcessor struct.

func (*JobProcessor) Add

func (j *JobProcessor) Add(job func(context.Context) error)

Add queues a job for processing.

func (*JobProcessor) Run

func (j *JobProcessor) Run(ctx context.Context) error

Run processes the job queue and returns the first error encountered, if any.

func (*JobProcessor) Stop

func (j *JobProcessor) Stop()

Stop cancels all queued jobs.

func (*JobProcessor) Wait

func (j *JobProcessor) Wait() error

Wait waits for all jobs to finish processing and returns the first error encountered, if any.

Jump to

Keyboard shortcuts

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