Documentation ¶
Overview ¶
Package io contains the definition of the IO Provider, as well as various implementations of the concept.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyExists = errors.New("already exists")
Error returned if data is found during a "Put" call.
var ErrNotFound = errors.New("not found")
Error returned if data is not found during a "Get" or "Update" call.
Functions ¶
This section is empty.
Types ¶
type Bolt ¶
type Bolt struct {
// contains filtered or unexported fields
}
Mem implements an IO Provider backed by the key/value database bolt..
type DataType ¶
type DataType uint16
Types of data supported by an IO Provider.
type Mem ¶
type Mem struct {
// contains filtered or unexported fields
}
Mem implements an in-memory version of an IO Provider.
type Provider ¶
type Provider interface { // Put sends bytes to the IO Provider. The data is identified by an ID and a data type. // Should return ErrAlreadyExists if the data already exists in the IO Provider. Put(id []byte, dataType DataType, data []byte) error // Get fetches data from the IO Provider. The data is identified by an ID and a data type. // Should return ErrNotFound if the data does not exist in the IO Provider. Get(id []byte, dataType DataType) ([]byte, error) // Update is similar to Put but updates data previously sent to the IO Provider. // Should return ErrNotFound if the data does not exist in the IO Provider. Update(id []byte, dataType DataType, data []byte) error // Delete removes data previously sent to the IO Provider. // Should not error if the data does not exist in the IO Provider. Delete(id []byte, dataType DataType) error }
Provider is the interface an IO Provider must implement to handle data from D1.
type Proxy ¶ added in v1.0.18
type Proxy struct { Implementation Provider PutFunc func(id []byte, dataType DataType, data []byte) error GetFunc func(id []byte, dataType DataType) ([]byte, error) UpdateFunc func(id []byte, dataType DataType, data []byte) error DeleteFunc func(id []byte, dataType DataType) error }
Proxy is an IO Provider that wraps other IO Providers By default, it forwards calls directly to the implementation, but allows you to customize the behavior as you see fit by changing the individual functions as you see fit.
func NewProxy ¶ added in v1.0.18
NewProxy returns a basic implementation of Proxy that can be used as a basis for tests.