Documentation ¶
Overview ¶
Package ez3 provides an interface to persisting structs into a key-value store such as AWS S3.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewS3Client ¶
func NewS3Client(args S3ClientArgs) (*awsS3.Client, error)
NewS3Client creates a new S3 client for use with S3EZ3. This is a helper function for users who want to connect to an S3-compatible cloud that is not AWS.
Types ¶
type EZ3 ¶
type EZ3 interface { // Get retrieves a value from the store. Get(key string, dst Serializable) error // Set stores a value in the store. Set(key string, val Serializable) error // Del removes a value from the store. Del(key string) error // List lists all keys in the store with the given prefix. List(prefix string) (keys []string, err error) }
EZ3 is a persistence interface which supports de/serialization.
type MemoryEZ3 ¶
type MemoryEZ3 struct {
// contains filtered or unexported fields
}
MemoryEZ3 is an in-memory implementation of the EZ3 API.
func (MemoryEZ3) Get ¶
func (e MemoryEZ3) Get(key string, dst Serializable) error
Get retrieves a value from memory.
type S3Args ¶
type S3Args struct { Bucket string // Required. The bucket that holds stored data. Namespace string // Required. The namespace for this instance's keys. Client S3Client // Optional. If not provided, autoconfigures an AWS S3 client from your environment. }
S3Args is the set of arguments for creating a new S3-backed EZ3.
type S3Client ¶
type S3Client interface { PutObject(context.Context, *awsS3.PutObjectInput, ...func(*awsS3.Options)) (*awsS3.PutObjectOutput, error) GetObject(context.Context, *awsS3.GetObjectInput, ...func(*awsS3.Options)) (*awsS3.GetObjectOutput, error) DeleteObject(context.Context, *awsS3.DeleteObjectInput, ...func(*awsS3.Options)) (*awsS3.DeleteObjectOutput, error) ListObjectsV2(context.Context, *awsS3.ListObjectsV2Input, ...func(*awsS3.Options)) (*awsS3.ListObjectsV2Output, error) }
S3Client is the interface for an AWS S3-compatible client.
type S3ClientArgs ¶
type S3ClientArgs struct { Endpoint string // Required. The web endpoint of the S3 service. Usually starts with https:// Region string // Required. The region of the S3 service. UsePathStyle bool // Optional. If true, the S3 client will use path-style addressing. }
S3ClientArgs is the set of arguments for creating a new S3 client for use with S3EZ3.
type S3EZ3 ¶
type S3EZ3 struct {
// contains filtered or unexported fields
}
S3EZ3 is an implementation of EZ3 backed by an S3-compatible file store.
func (S3EZ3) Get ¶
func (s S3EZ3) Get(key string, dst Serializable) error
Get retrieves a value from S3.
type Serializable ¶
type Serializable interface { // Serialize serializes the struct's data into bytes. Serialize() ([]byte, error) // Deserialize deserializes the given bytes into the struct's data. Deserialize([]byte) error }
Serializable is a data type which supports de/serialization. Any data stored through EZ3 must implement this interface.
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
1_in_memory
Persist and retrieve a User object using the in-memory store.
|
Persist and retrieve a User object using the in-memory store. |
2_aws_s3
Persist and retrieve a User object using AWS S3.
|
Persist and retrieve a User object using AWS S3. |
3_backblaze_b2
Persist and retrieve a User object using Backblaze B2
|
Persist and retrieve a User object using Backblaze B2 |