Skip to content

Commit

Permalink
✅ add internal/s3/reader/option test (#630)
Browse files Browse the repository at this point in the history
* ✅ ♻️ add internal/db/storage/s3/reader/option test

Signed-off-by: vankichi <[email protected]>

* ✅ fix

Signed-off-by: vankichi <[email protected]>

* ✅ fix

Signed-off-by: vankichi <[email protected]>
  • Loading branch information
vankichi authored Aug 24, 2020
1 parent 0f36d32 commit 764a4bb
Show file tree
Hide file tree
Showing 2 changed files with 416 additions and 338 deletions.
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

0 comments on commit 764a4bb

Please sign in to comment.