Documentation ¶
Index ¶
- type Async
- func (s *Async) EraseExisting(ctx context.Context, root string) error
- func (s *Async) FS() content.FS
- func (s *Async) Finish(context.Context) error
- func (s *Async) Read(ctx context.Context, prefix, name string) (content.Type, []byte, error)
- func (s *Async) ReadV(ctx context.Context, prefix string, names []string, fn ReadFunc) error
- func (s *Async) Write(ctx context.Context, prefix, name string, data []byte) error
- type ReadFunc
- type Sync
- func (s *Sync) EraseExisting(ctx context.Context, root string) error
- func (s *Sync) FS() content.FS
- func (s *Sync) Finish(context.Context) error
- func (s *Sync) Read(ctx context.Context, prefix, name string) (content.Type, []byte, error)
- func (s *Sync) ReadV(ctx context.Context, prefix string, names []string, fn ReadFunc) error
- func (s *Sync) Write(ctx context.Context, prefix, name string, data []byte) error
- type T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Async ¶
type Async struct {
// contains filtered or unexported fields
}
AsyncWrite represents a store for objects with asynchronous writes. Reads are synchronous. The caller must ensure that Finish is called to ensure that all writes have completed.
func NewAsync ¶
NewAsync returns a new instance of Async with the specified concurrency. If concurrency is less than or equal to zero, the number of CPUs is used.
func (*Async) EraseExisting ¶
EraseExisting deletes all contents of the store beneath root.
func (*Async) Finish ¶
Finish waits for all queued writes to complete and returns any errors encountered during the writes.
func (*Async) Read ¶
Read retrieves the object type and serialized data at the specified prefix and name from the store. The caller is responsible for using the returned type to decode the data into an appropriate object.
func (*Async) ReadV ¶
ReadV retrieves the objects with the specified names from the store and calls fn for each object. The read operations are performed concurrently.
func (*Async) Write ¶
Write queues a write request for the specified prefix and name in the store. There is no guarantee that the write will have completed when this method returns. The error code returned is an indication that the write request was queued and will only ever context.Canceled if non-nil.
type ReadFunc ¶
type ReadFunc func(ctx context.Context, prefix, name string, typ content.Type, data []byte, err error) error
ReadFunc is called by ReadV for each object read from the store. If the read operation returned an error it is passed to ReadFunc and if then returned by ReadFunc it will cause the entire ReadV operation to terminate and return an error.
type Sync ¶
type Sync struct {
// contains filtered or unexported fields
}
Sync represents a synchronous store for objects, ie. it implements content.ObjectStore. It uses an instance of content.FS to store and retrieve objects.
func NewSync ¶
NewSync returns a new instance of Sync backed by the supplied content.FS and storing the specified objects encoded using the specified encodings.
func (*Sync) EraseExisting ¶
EraseExisting deletes all contents of the store beneath root.
func (*Sync) Read ¶
Read retrieves the object type and serialized data at the specified prefix and name from the store. The caller is responsible for using the returned type to decode the data into an appropriate object.
type T ¶
type T interface { content.ObjectStore EraseExisting(ctx context.Context, root string) error FS() content.FS ReadV(ctx context.Context, prefix string, names []string, fn ReadFunc) error Finish(context.Context) error }
T represents a common interface for both synchronous and asynchronous stores.