shared

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package shared provides what the retrievers and the retriever manager share: the HTTP call and the read of a file

Index

Constants

This section is empty.

Variables

View Source
var ErrUnstable = errors.New("the file changed while it was being read")

ErrUnstable is returned when the file changed while it was being read (an in-place rewrite): the content read may be partial, so it is not returned. Retry on the next refresh.

Functions

func CallHTTPAPI

func CallHTTPAPI(
	ctx context.Context,
	url, method, body string,
	timeout time.Duration,
	header http.Header,
	httpClient httpclient.HTTPClient,
) (*http.Response, error)

CallHTTPAPI is the default function to make an HTTP call in the retrievers.

func Fetch added in v1.3.0

func Fetch(ctx context.Context, req *Request) ([]byte, error)

Fetch sends the request and returns the body of the response: the call of the HTTP retriever and of the retrievers that wrap it. A status of 400 or more is an error that names the URL without its secrets and the status.

func ReadFile added in v1.3.0

func ReadFile(fsys fs.FS, path string) ([]byte, error)

ReadFile reads the file at path, from fsys when it is not nil (path is then relative to fsys) and from the operating system otherwise. It compares the size and the modification time of the open file before and after the read, and returns ErrUnstable when they differ or when the number of bytes read is not the size of a regular file: a writer was rewriting the file in place.

Types

type Request added in v1.3.0

type Request struct {
	// Client sends the request. A nil client is created with the Timeout, as [CallHTTPAPI] does.
	Client httpclient.HTTPClient
	// Header is sent with the request.
	Header http.Header
	// URL is the address to call. It is mandatory.
	URL string
	// Method is the HTTP method, GET when empty.
	Method string
	// Body is the body of the request, empty by default.
	Body string
	// Timeout bounds the call when no client is given, 10 seconds when not positive.
	Timeout time.Duration
}

Request is one HTTP call of a retriever that reads a flag file: see Fetch.

Jump to

Keyboard shortcuts

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