Skip to content

Commit a0887ff

Browse files
committed
refactor(minio): address PR review comments
1 parent 4904a18 commit a0887ff

File tree

7 files changed

+6
-28
lines changed

7 files changed

+6
-28
lines changed

cmd/main/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ func main() {
167167
compStore,
168168
ms,
169169
service.NewRetentionHandler(),
170-
compStore.GetBinaryFetcher(),
171170
artifactPublicServiceClient,
172171
artifactPrivateServiceClient,
173172
)

cmd/worker/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ func main() {
121121
MemoryStore: ms,
122122
ArtifactPublicServiceClient: artifactPublicServiceClient,
123123
ArtifactPrivateServiceClient: artifactPrivateServiceClient,
124-
BinaryFetcher: compStore.GetBinaryFetcher(),
125124
PipelinePublicServiceClient: pipelinePublicServiceClient,
126125
},
127126
)

pkg/component/store/store.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,6 @@ func Init(param InitParams) *Store {
249249
return compStore
250250
}
251251

252-
// GetBinaryFetcher returns the binary fetcher instance used by the store
253-
func (s *Store) GetBinaryFetcher() binary.Fetcher {
254-
return s.binaryFetcher
255-
}
256-
257252
// Import loads the component definitions into memory.
258253
func (s *Store) Import(comp base.IComponent) {
259254
c := &component{comp: comp}

pkg/data/binary/fetcher.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,20 @@ import (
1010
"github.com/go-resty/resty/v2"
1111
)
1212

13-
// Fetcher is an interface that fetches binary data from a URL.
14-
type Fetcher interface {
15-
FetchFromURL(ctx context.Context, url string) (body []byte, contentType string, filename string, err error)
16-
}
17-
18-
type fetcher struct {
13+
// Fetcher is a struct that fetches binary data from a URL.
14+
type Fetcher struct {
1915
httpClient *resty.Client
2016
}
2117

22-
// NewFetcher creates a new BinaryFetcher instance.
18+
// NewFetcher creates a new Fetcher instance.
2319
func NewFetcher() Fetcher {
24-
return &fetcher{
20+
return Fetcher{
2521
httpClient: resty.New().SetRetryCount(3),
2622
}
2723
}
2824

2925
// FetchFromURL fetches binary data from a URL.
30-
func (f *fetcher) FetchFromURL(ctx context.Context, url string) (body []byte, contentType string, filename string, err error) {
26+
func (f *Fetcher) FetchFromURL(ctx context.Context, url string) (body []byte, contentType string, filename string, err error) {
3127
if strings.HasPrefix(url, "data:") {
3228
return f.convertDataURIToBytes(url)
3329
}
@@ -52,7 +48,7 @@ func (f *fetcher) FetchFromURL(ctx context.Context, url string) (body []byte, co
5248
return
5349
}
5450

55-
func (f *fetcher) convertDataURIToBytes(url string) (b []byte, contentType string, filename string, err error) {
51+
func (f *Fetcher) convertDataURIToBytes(url string) (b []byte, contentType string, filename string, err error) {
5652
slices := strings.Split(url, ",")
5753
if len(slices) == 1 {
5854
b, err = base64.StdEncoding.DecodeString(url)

pkg/service/main.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ func NewService(
129129
componentStore *componentstore.Store,
130130
memory *memory.Store,
131131
retentionHandler MetadataRetentionHandler,
132-
binaryFetcher binary.Fetcher,
133132
artifactPublicServiceClient artifactpb.ArtifactPublicServiceClient,
134133
artifactPrivateServiceClient artifactpb.ArtifactPrivateServiceClient,
135134
) Service {
@@ -148,7 +147,6 @@ func NewService(
148147
memory: memory,
149148
log: zapLogger,
150149
retentionHandler: retentionHandler,
151-
binaryFetcher: binaryFetcher,
152150
artifactPublicServiceClient: artifactPublicServiceClient,
153151
artifactPrivateServiceClient: artifactPrivateServiceClient,
154152
}

pkg/service/pipeline_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"go.temporal.io/sdk/client"
1313

1414
"github.com/instill-ai/pipeline-backend/pkg/acl"
15-
"github.com/instill-ai/pipeline-backend/pkg/data/binary"
1615
"github.com/instill-ai/pipeline-backend/pkg/datamodel"
1716
"github.com/instill-ai/pipeline-backend/pkg/memory"
1817
"github.com/instill-ai/pipeline-backend/pkg/mock"
@@ -69,9 +68,6 @@ func TestService_UpdateNamespacePipelineByID(t *testing.T) {
6968
converter := mock.NewConverterMock(mc)
7069
mgmtPrivateClient := mock.NewMgmtPrivateServiceClientMock(mc)
7170

72-
// Create a simple binary fetcher for testing
73-
binaryFetcher := binary.NewFetcher()
74-
7571
service := newService(
7672
serviceConfig{
7773
repository: repo,
@@ -82,7 +78,6 @@ func TestService_UpdateNamespacePipelineByID(t *testing.T) {
8278
mgmtPrivateServiceClient: mgmtPrivateClient,
8379
componentStore: nil,
8480
memory: memory.NewStore(nil, nil),
85-
binaryFetcher: binaryFetcher,
8681
},
8782
)
8883

@@ -131,7 +126,6 @@ type serviceConfig struct {
131126
componentStore *componentstore.Store
132127
memory *memory.Store
133128
retentionHandler MetadataRetentionHandler
134-
binaryFetcher binary.Fetcher
135129
artifactPublicServiceClient artifactpb.ArtifactPublicServiceClient
136130
artifactPrivateServiceClient artifactpb.ArtifactPrivateServiceClient
137131
}
@@ -154,7 +148,6 @@ func newService(cfg serviceConfig) Service {
154148
cfg.componentStore,
155149
cfg.memory,
156150
cfg.retentionHandler,
157-
cfg.binaryFetcher,
158151
cfg.artifactPublicServiceClient,
159152
cfg.artifactPrivateServiceClient,
160153
)

pkg/worker/main.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ type WorkerConfig struct {
6666
MemoryStore *memory.Store
6767
ArtifactPublicServiceClient artifactpb.ArtifactPublicServiceClient
6868
ArtifactPrivateServiceClient artifactpb.ArtifactPrivateServiceClient
69-
BinaryFetcher binary.Fetcher
7069
PipelinePublicServiceClient pipelinepb.PipelinePublicServiceClient
7170
}
7271

@@ -100,7 +99,6 @@ func NewWorker(
10099
log: logger,
101100
artifactPublicServiceClient: workerConfig.ArtifactPublicServiceClient,
102101
artifactPrivateServiceClient: workerConfig.ArtifactPrivateServiceClient,
103-
binaryFetcher: workerConfig.BinaryFetcher,
104102
pipelinePublicServiceClient: workerConfig.PipelinePublicServiceClient,
105103
}
106104
}

0 commit comments

Comments
 (0)