Skip to content

Commit

Permalink
Update AWS client functions to lowercase.Set HTTP client attribute to…
Browse files Browse the repository at this point in the history
… lowercase.Refactor function calls to lowercase for consistency
  • Loading branch information
m-mizutani committed Nov 20, 2024
1 parent 0ecb55a commit 36c7965
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions source/falcon_data_replicator/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ type awsConfig struct {
type client struct {
AWS awsConfig

NewSQS func(cfg aws.Config, optFns ...func(*sqs.Options)) interfaces.SQS `json:"-"`
NewS3 func(cfg aws.Config, optFns ...func(*s3.Options)) interfaces.S3 `json:"-"`
newSQS func(cfg aws.Config, optFns ...func(*sqs.Options)) interfaces.SQS
newS3 func(cfg aws.Config, optFns ...func(*s3.Options)) interfaces.S3

MaxPull int
}
Expand All @@ -78,10 +78,10 @@ func New(awsRegion, awsAccessKeyId string, awsSecretAccessKey secret.String, sqs
cred: credentials.NewStaticCredentialsProvider(awsAccessKeyId, awsSecretAccessKey.Unsafe(), ""),
},

NewSQS: func(cfg aws.Config, optFns ...func(*sqs.Options)) interfaces.SQS {
newSQS: func(cfg aws.Config, optFns ...func(*sqs.Options)) interfaces.SQS {
return sqs.NewFromConfig(cfg, optFns...)
},
NewS3: func(cfg aws.Config, optFns ...func(*s3.Options)) interfaces.S3 {
newS3: func(cfg aws.Config, optFns ...func(*s3.Options)) interfaces.S3 {
return s3.NewFromConfig(cfg, optFns...)
},

Expand Down Expand Up @@ -112,8 +112,8 @@ func New(awsRegion, awsAccessKeyId string, awsSecretAccessKey secret.String, sqs
}

// Create AWS service clients
s3Client := x.NewS3(cfg)
sqsClient := x.NewSQS(cfg)
s3Client := x.newS3(cfg)
sqsClient := x.newSQS(cfg)

// Receive messages from SQS queue
input := &sqs.ReceiveMessageInput{
Expand Down
8 changes: 4 additions & 4 deletions source/one_password/one_password.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type config struct {
MaxPages int
Limit int
Duration time.Duration
HTTPClient interfaces.HTTPClient
httpClient interfaces.HTTPClient
}

type Option func(*config)
Expand Down Expand Up @@ -62,7 +62,7 @@ func WithDuration(d time.Duration) Option {
// WithHTTPClient sets the HTTP client to send requests. Default is http.DefaultClient. This option is mainly for testing.
func WithHTTPClient(httpClient interfaces.HTTPClient) Option {
return func(x *config) {
x.HTTPClient = httpClient
x.httpClient = httpClient
}
}

Expand All @@ -73,7 +73,7 @@ func New(apiToken secret.String, opts ...Option) hatchery.Source {
MaxPages: 0,
Limit: 100,
Duration: time.Minute * 10,
HTTPClient: http.DefaultClient,
httpClient: http.DefaultClient,
}

for _, opt := range opts {
Expand Down Expand Up @@ -133,7 +133,7 @@ func (x *config) crawl(ctx context.Context, p *hatchery.Pipe, end time.Time, seq
httpReq.Header.Set("Content-Type", "application/json")
httpReq.Header.Set("Authorization", "Bearer "+x.APIToken.Unsafe())

httpResp, err := x.HTTPClient.Do(httpReq)
httpResp, err := x.httpClient.Do(httpReq)
if err != nil {
return nil, goerr.Wrap(err, "failed to send HTTP request")
}
Expand Down
8 changes: 4 additions & 4 deletions source/slack/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ type config struct {
Duration time.Duration

// httpClient is a HTTP client to send requests to Slack API.
HTTPClient interfaces.HTTPClient
httpClient interfaces.HTTPClient
}

func New(accessToken secret.String, options ...Option) hatchery.Source {
c := &config{
AccessToken: accessToken,
HTTPClient: http.DefaultClient,
httpClient: http.DefaultClient,
Duration: 10 * time.Minute,
Limit: 100,
MaxPages: 0,
Expand Down Expand Up @@ -100,7 +100,7 @@ func WithDuration(duration time.Duration) Option {
// WithHTTPClient sets a HTTP client to send requests to Slack API.
func WithHTTPClient(httpClient interfaces.HTTPClient) Option {
return func(c *config) {
c.HTTPClient = httpClient
c.httpClient = httpClient
}
}

Expand Down Expand Up @@ -136,7 +136,7 @@ func (x *config) crawl(ctx context.Context, end time.Time, seq int, cursor strin
httpReq.Header.Set("Content-Type", "application/json")
httpReq.Header.Set("Authorization", "Bearer "+x.AccessToken.Unsafe())

httpResp, err := x.HTTPClient.Do(httpReq)
httpResp, err := x.httpClient.Do(httpReq)
if err != nil {
return nil, goerr.Wrap(err, "failed to send HTTP request")
}
Expand Down

0 comments on commit 36c7965

Please sign in to comment.