automerge_s3_sync

package module
v0.0.0-...-4df0d72 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 24 Imported by: 0

README

automerge-s3-sync

A Go library for syncronising automerge documents via a remote S3 API

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrObjectNotFound = errors.New("object not found")

Functions

func AssertContains

func AssertContains[E comparable](t *testing.T, container []E, item E) bool

func AssertEqual

func AssertEqual[k any](t *testing.T, actual, expected k) bool

func AssertErrorEqual

func AssertErrorEqual(t *testing.T, actual error, expected string) bool

func AssertErrorIs

func AssertErrorIs(t *testing.T, actual error, expected error) bool

func MustAssertEqual

func MustAssertEqual[k any](t *testing.T, actual, expected k)

Types

type ClientEncryptedS3

type ClientEncryptedS3 struct {
	S3
	BlockCipher cipher.Block
}

func (*ClientEncryptedS3) GetObject

func (s *ClientEncryptedS3) GetObject(ctx context.Context, key string, dst io.Writer) (meta map[string]string, err error)

func (*ClientEncryptedS3) PutObject

func (s *ClientEncryptedS3) PutObject(ctx context.Context, key string, meta map[string]string, body io.Reader) (err error)

type HttpDoer

type HttpDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

type HttpRoundTripperFunc

type HttpRoundTripperFunc func(*http.Request) (*http.Response, error)

func WrapSigV4RoundTripper

func WrapSigV4RoundTripper(rt http.RoundTripper, clock func() time.Time, region, keyId, secretKey string) HttpRoundTripperFunc

WrapSigV4RoundTripper wraps a http client with a signer

func (HttpRoundTripperFunc) RoundTrip

func (f HttpRoundTripperFunc) RoundTrip(req *http.Request) (*http.Response, error)

type InMemoryS3

type InMemoryS3 struct {
	// contains filtered or unexported fields
}

func (*InMemoryS3) DeleteObject

func (i *InMemoryS3) DeleteObject(ctx context.Context, key string) error

func (*InMemoryS3) GetObject

func (i *InMemoryS3) GetObject(ctx context.Context, key string, dst io.Writer) (meta map[string]string, err error)

func (*InMemoryS3) HeadObject

func (i *InMemoryS3) HeadObject(ctx context.Context, key string) (size int64, meta map[string]string, err error)

func (*InMemoryS3) ListObjects

func (i *InMemoryS3) ListObjects(ctx context.Context, prefix string, delimiter string) (keys []string, sizes []int64, prefixes []string, err error)

func (*InMemoryS3) PutObject

func (i *InMemoryS3) PutObject(ctx context.Context, key string, meta map[string]string, body io.Reader) (err error)

type ListBucketCommonPrefix

type ListBucketCommonPrefix struct {
	Prefix string `xml:"Prefix"`
}

type ListBucketObject

type ListBucketObject struct {
	Key  string `xml:"Key"`
	Size int64  `xml:"Size"`
}

type ListBucketResult

type ListBucketResult struct {
	IsTruncated           bool                     `xml:"IsTruncated"`
	NextContinuationToken string                   `xml:"NextContinuationToken"`
	Contents              []ListBucketObject       `xml:"Contents"`
	CommonPrefixes        []ListBucketCommonPrefix `xml:"CommonPrefixes"`
}

type S3

type S3 interface {
	GetObject(ctx context.Context, key string, dst io.Writer) (meta map[string]string, err error)
	HeadObject(ctx context.Context, key string) (size int64, meta map[string]string, err error)
	ListObjects(ctx context.Context, prefix string, delimiter string) (keys []string, sizes []int64, prefixes []string, err error)
	PutObject(ctx context.Context, key string, meta map[string]string, body io.Reader) (err error)
	DeleteObject(ctx context.Context, key string) error
}

func NewS3Impl

func NewS3Impl(client HttpDoer, bucketUrl *url.URL) S3

type S3Impl

type S3Impl struct {
	// contains filtered or unexported fields
}

func (*S3Impl) DeleteObject

func (s *S3Impl) DeleteObject(ctx context.Context, key string) error

func (*S3Impl) GetObject

func (s *S3Impl) GetObject(ctx context.Context, key string, dst io.Writer) (meta map[string]string, err error)

func (*S3Impl) HeadObject

func (s *S3Impl) HeadObject(ctx context.Context, key string) (size int64, meta map[string]string, err error)

func (*S3Impl) ListObjects

func (s *S3Impl) ListObjects(ctx context.Context, prefix string, delimiter string) (keys []string, sizes []int64, prefixes []string, err error)

func (*S3Impl) PutObject

func (s *S3Impl) PutObject(ctx context.Context, key string, meta map[string]string, body io.Reader) (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL