Documentation ¶
Index ¶
Constants ¶
const ( // DefaultBatchSize is the batch size we initialize when constructing a batch delete client. // This value is used when calling DeleteObjects. This represents how many objects to delete // per DeleteObjects call. DefaultBatchSize = 100 )
const ( // ErrDeleteBatchFailCode represents an error code which will be returned // only when DeleteObjects.Errors has an error that does not contain a code. ErrDeleteBatchFailCode = "DeleteBatchError" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BatchDelete ¶
BatchDelete will use the s3 package's service client to perform a batch delete.
func NewBatchDelete ¶
func NewBatchDelete(c client.ConfigProvider, options ...func(*BatchDelete)) *BatchDelete
NewBatchDelete will return a new delete client that can delete a batched amount of objects.
Example:
batcher := s3manager.NewBatchDelete(sess, size) objects := []BatchDeleteObject{ { Object: &s3.DeleteObjectInput { Key: aws.String("key"), Bucket: aws.String("bucket"), }, }, } if err := batcher.Delete(aws.BackgroundContext(), &s3manager.DeleteObjectsIterator{ Objects: objects, }); err != nil { return err }
func NewBatchDeleteWithClient ¶
func NewBatchDeleteWithClient(s3client s3iface.S3API, options ...func(*BatchDelete)) *BatchDelete
NewBatchDeleteWithClient will return a new delete client that can delete a batched amount of objects.
Example:
batcher := s3manager.NewBatchDeleteWithClient(client, size) objects := []BatchDeleteObject{ { Object: &s3.DeleteObjectInput { Key: aws.String("key"), Bucket: aws.String("bucket"), }, }, } if err := batcher.Delete(aws.BackgroundContext(), &s3manager.DeleteObjectsIterator{ Objects: objects, }); err != nil { return err }
func (*BatchDelete) Delete ¶
func (d *BatchDelete) Delete(ctx aws.Context, iter BatchDeleteIterator, opts ...func(input *s3.DeleteObjectsInput)) error
Delete will use the iterator to queue up objects that need to be deleted. Once the batch size is met, this will call the deleteBatch function.
type BatchDeleteIterator ¶
type BatchDeleteIterator interface { Next() bool Err() error DeleteObject() BatchDeleteObject }
BatchDeleteIterator is an interface that uses the scanner pattern to iterate through what needs to be deleted.
func NewDeleteListIterator ¶
func NewDeleteListIterator(svc s3iface.S3API, input *s3.ListObjectsInput, opts ...func(*DeleteListIterator)) BatchDeleteIterator
NewDeleteListIterator will return a new DeleteListIterator.
type BatchDeleteObject ¶
type BatchDeleteObject struct { Object *s3.DeleteObjectInput // After will run after each iteration during the batch process. This function will // be executed whether the request was successful. After func() error }
BatchDeleteObject is a wrapper object for calling the batch delete operation.
type BatchError ¶
type BatchError struct { Errors Errors // contains filtered or unexported fields }
BatchError will contain the key and bucket of the object that failed to either upload or download.
func (*BatchError) Code ¶
func (err *BatchError) Code() string
Code will return the code associated with the batch error.
func (*BatchError) Error ¶
func (err *BatchError) Error() string
func (*BatchError) Message ¶
func (err *BatchError) Message() string
Message will return the message associated with the batch error.
func (*BatchError) OrigErr ¶
func (err *BatchError) OrigErr() error
OrigErr will return the original error. Which, in this case, will always be nil for batched operations.
type DeleteListIterator ¶
type DeleteListIterator struct { Bucket *string Paginator request.Pagination // contains filtered or unexported fields }
DeleteListIterator is an alternative iterator for the BatchDelete client. This will iterate through a list of objects and delete the objects.
Example:
iter := &s3manager.DeleteListIterator{ Client: svc, Input: &s3.ListObjectsInput{ Bucket: aws.String("bucket"), MaxKeys: aws.Int64(5), }, Paginator: request.Pagination{ NewRequest: func() (*request.Request, error) { var inCpy *ListObjectsInput if input != nil { tmp := *input inCpy = &tmp } req, _ := c.ListObjectsRequest(inCpy) return req, nil }, }, } batcher := s3manager.NewBatchDeleteWithClient(svc) if err := batcher.Delete(aws.BackgroundContext(), iter); err != nil { return err }
func (*DeleteListIterator) DeleteObject ¶
func (iter *DeleteListIterator) DeleteObject() BatchDeleteObject
DeleteObject will return the current object to be deleted.
func (*DeleteListIterator) Err ¶
func (iter *DeleteListIterator) Err() error
Err will return the last known error from Next.
func (*DeleteListIterator) Next ¶
func (iter *DeleteListIterator) Next() bool
Next will use the S3API client to iterate through a list of objects.
type DeleteObjectsIterator ¶
type DeleteObjectsIterator struct { Objects []BatchDeleteObject // contains filtered or unexported fields }
DeleteObjectsIterator is an interface that uses the scanner pattern to iterate through a series of objects to be deleted.
func (*DeleteObjectsIterator) DeleteObject ¶
func (iter *DeleteObjectsIterator) DeleteObject() BatchDeleteObject
DeleteObject will return the BatchDeleteObject at the current batched index.
func (*DeleteObjectsIterator) Err ¶
func (iter *DeleteObjectsIterator) Err() error
Err will return an error. Since this is just used to satisfy the BatchDeleteIterator interface this will only return nil.
func (*DeleteObjectsIterator) Next ¶
func (iter *DeleteObjectsIterator) Next() bool
Next will increment the default iterators index and ensure that there is another object to iterator to.