Documentation
¶
Overview ¶
Package filepool keeps a set of reusable write handles open on a single remote path, one per connection, so several goroutines can write to the same file at once without sharing a handle.
It is used by backends that implement fs.OpenWriterAter over a connection pool, where the core writes the chunks of a large file concurrently at non-overlapping offsets.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pool ¶
type Pool[T any] struct { // contains filtered or unexported fields }
Pool hands out handles of type T for a single file. Handles are reused when free and opened on demand otherwise. It is safe for concurrent use.
The zero value is not usable; call New.
func New ¶
func New[T any](ctx context.Context, open func(context.Context) (T, error), release func(handle T, err error) error) *Pool[T]
New returns a Pool.
open opens a fresh handle on its own connection. release closes a handle and returns its connection: err is the error that made the handle unusable (nil when the handle is simply being drained) and the returned error is the result of closing it.
func (*Pool[T]) Drain ¶
Drain releases every free handle, closing them concurrently, and returns the first error encountered.