Documentation
¶
Index ¶
- Variables
- func FetchLastModDatesForURLs(ctx context.Context, executor *Executor, ...) ([]time.Time, error)
- type Executor
- func (e Executor) AddFutureRequests(ctx context.Context, urls ...string) []*Future
- func (e Executor) AddFutureRequestsWithInterceptor(ctx context.Context, modifyRequest func(r *http.Request) error, urls ...string) []*Future
- func (e Executor) AddRequests(ctx context.Context, urls ...string) []chan Result
- func (e Executor) AddRequestsWithInterceptor(ctx context.Context, modifyRequest func(r *http.Request) error, urls ...string) []chan Result
- func (e Executor) Close()
- type Future
- type Option
- type Options
- type Result
Constants ¶
This section is empty.
Variables ¶
var (
ErrRequestFailed = errors.New("http request failed")
)
Functions ¶
Types ¶
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor is the central bulk request maintainer.
func NewExecutor ¶
NewExecutor instantiates a new Executor.
func (Executor) AddFutureRequests ¶
AddFutureRequests i one or more urls to be called and wrapped in a bulk.Future.
func (Executor) AddFutureRequestsWithInterceptor ¶
func (e Executor) AddFutureRequestsWithInterceptor( ctx context.Context, modifyRequest func(r *http.Request) error, urls ...string, ) []*Future
AddFutureRequestsWithInterceptor issues one or more urls to be called and wrapped in a bulk.Future. For each call, optional hooks for modifying the request are executed (if not nil).
func (Executor) AddRequests ¶
AddRequests issues one or more urls to be called.
func (Executor) AddRequestsWithInterceptor ¶
func (e Executor) AddRequestsWithInterceptor( ctx context.Context, modifyRequest func(r *http.Request) error, urls ...string, ) []chan Result
AddRequestsWithInterceptor issues one or more urls to be called. For each call, optional hooks for modifying the request are executed (if not nil).
type Future ¶
type Future struct {
// contains filtered or unexported fields
}
Future is a holder for a bulk.Response channel, which allows to safely "read" the result multiple times
func (*Future) Get ¶
Get retrieves the underlying result, and caches it. Subsequent calls to get will not query the channel, but return the cached result.
func (*Future) UnmarshalResponse ¶
UnmarshalResponse is the concurrency and multi-read safe version of the Result UnmarshalResponse function.
First, the result is retrieved and cached as described in the Get() method. Afterwards, (if not done already) the body of the response stream is read (and afterwards closed!), and also cached. Finally, this cached body is then used for all unmarshalling attempts.
This effectively means, that the same response can be marshalled into different target types via this function.
If the Result did have an error, or something goes wrong while unmarshalling, the error is returned (result error of course taking precedence). If the error originated from reading the body, all subsequent calls return the same error, and no attempt to read the stream will be done again.
type Option ¶
type Option func(*Options)
func Client ¶
Client sets the http client, which is used for issuing requests. Per default, the default http client is used.
func ConcurrencyLimit ¶
ConcurrencyLimit regulates how many requests will be done at the same time Note, you need a http client, which is actually capable of doing multiple requests at the same time, for this to work properly. You can use -1 to indicate no limit - use with care!
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result is a simple data holder for bulk request results.
func (Result) URL ¶
URL returns the originally requested url. If you want to know the final URL, look at the HTTP response.
func (Result) UnmarshalResponse ¶
UnmarshalResponse unmarshals the http response directly into the provided interface type (remember to provide a reference, not a value!), and closes the stream afterwards.
If the Result did have an error, or something goes wrong while unmarshalling, the error is returned (result error of course taking precedence).