Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add internal/s3/reader/option test #630

Merged
merged 3 commits into from
Aug 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions internal/db/storage/blob/s3/reader/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/vdaas/vald/internal/errgroup"
)

// Option represents the functional option for reader.
type Option func(r *reader)

var (
Expand All @@ -32,6 +33,7 @@ var (
}
)

// WithErrGroup returns the option to set the eg.
func WithErrGroup(eg errgroup.Group) Option {
return func(r *reader) {
if eg != nil {
Expand All @@ -40,6 +42,7 @@ func WithErrGroup(eg errgroup.Group) Option {
}
}

// WithService returns the option to set the service.
func WithService(s *s3.S3) Option {
return func(r *reader) {
if s != nil {
Expand All @@ -48,34 +51,43 @@ func WithService(s *s3.S3) Option {
}
}

// WithBucket returns the option to set the bucket.
func WithBucket(bucket string) Option {
return func(r *reader) {
r.bucket = bucket
}
}

// WithKey returns the option to set the key.
func WithKey(key string) Option {
return func(r *reader) {
r.key = key
}
}

// WithMaxChunkSize retunrs the option to set the maxChunkSize.
func WithMaxChunkSize(size int64) Option {
return func(r *reader) {
r.maxChunkSize = size
}
}

// WithBackoff returns the option to set the backoffEnabled.
func WithBackoff(enabled bool) Option {
return func(r *reader) {
r.backoffEnabled = enabled
}
}

// WithBackoffOpts returns the option to set the backoffOpts.
func WithBackoffOpts(opts ...backoff.Option) Option {
return func(r *reader) {
if opts == nil {
return
}
if r.backoffOpts == nil {
r.backoffOpts = opts
return
}

r.backoffOpts = append(r.backoffOpts, opts...)
Expand Down
Loading