Skip to content

Commit

Permalink
Use named type for object handler (#308)
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Shishkin <me@teran.ru>
  • Loading branch information
teran authored Jan 11, 2025
1 parent 868e604 commit f32ebbc
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cli/service/source/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func New(dir string, c cache.CacheRepository) source.Source {
}
}

func (l *local) Process(ctx context.Context, handler func(ctx context.Context, obj source.Object) error) error {
func (l *local) Process(ctx context.Context, handler source.ObjectHandler) error {
log.WithFields(log.Fields{
"source_type": sourceType,
"directory": l.dir,
Expand Down
2 changes: 1 addition & 1 deletion cli/service/source/mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func New() *Mock {
return &Mock{}
}

func (m *Mock) Process(ctx context.Context, handler func(ctx context.Context, obj source.Object) error) error {
func (m *Mock) Process(ctx context.Context, handler source.ObjectHandler) error {
args := m.Called()
return args.Error(0)
}
4 changes: 3 additions & 1 deletion cli/service/source/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ type Object struct {
MimeType string
}

type ObjectHandler func(ctx context.Context, obj Object) error

type Source interface {
Process(ctx context.Context, handler func(ctx context.Context, obj Object) error) error
Process(ctx context.Context, handler ObjectHandler) error
}
2 changes: 1 addition & 1 deletion cli/service/source/yum/yum.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func New(repoURL string, rpmGPGKeyURL, rpmGPGKeySHA256 *string) source.Source {
}
}

func (r *repository) Process(ctx context.Context, handler func(ctx context.Context, obj source.Object) error) error {
func (r *repository) Process(ctx context.Context, handler source.ObjectHandler) error {
log.WithFields(log.Fields{
"repository_url": r.repoURL,
}).Info("running creating version from YUM repository ...")
Expand Down

0 comments on commit f32ebbc

Please sign in to comment.