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 ¶
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
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
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.