@@ -9,14 +9,18 @@ import (
9
9
"os"
10
10
"time"
11
11
12
- "github.com/aws/aws-lambda-go/lambda"
12
+ awslambda "github.com/aws/aws-lambda-go/lambda"
13
13
"github.com/aws/aws-sdk-go-v2/aws"
14
+ v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4"
14
15
"github.com/aws/aws-sdk-go-v2/config"
15
16
"github.com/aws/aws-sdk-go-v2/service/cloudwatch"
17
+ "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider"
16
18
"github.com/ministryofjustice/opg-modernising-lpa/internal/donor"
17
19
"github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo"
18
20
"github.com/ministryofjustice/opg-modernising-lpa/internal/event"
21
+ "github.com/ministryofjustice/opg-modernising-lpa/internal/lambda"
19
22
"github.com/ministryofjustice/opg-modernising-lpa/internal/localize"
23
+ "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore"
20
24
"github.com/ministryofjustice/opg-modernising-lpa/internal/notify"
21
25
"github.com/ministryofjustice/opg-modernising-lpa/internal/scheduled"
22
26
"github.com/ministryofjustice/opg-modernising-lpa/internal/search"
40
44
searchIndexingEnabled = os .Getenv ("SEARCH_INDEXING_DISABLED" ) != "1"
41
45
tableName = os .Getenv ("LPAS_TABLE" )
42
46
xrayEnabled = os .Getenv ("XRAY_ENABLED" ) == "1"
47
+ lpaStoreBaseURL = os .Getenv ("LPA_STORE_BASE_URL" )
48
+ lpaStoreSecretARN = os .Getenv ("LPA_STORE_SECRET_ARN" )
43
49
44
50
Tag string
45
51
@@ -81,8 +87,13 @@ func handleRunSchedule(ctx context.Context) error {
81
87
return err
82
88
}
83
89
84
- donorStore := donor .NewStore (dynamoClient , eventClient , logger , searchClient )
90
+ lambdaClient := lambda .New (cfg , v4 .NewSigner (), httpClient , time .Now )
91
+ lpaStoreClient := lpastore .New (lpaStoreBaseURL , secretsClient , lpaStoreSecretARN , lambdaClient )
92
+
85
93
scheduledStore := scheduled .NewStore (dynamoClient )
94
+ donorStore := donor .NewStore (dynamoClient , eventClient , logger , searchClient )
95
+ certificateProviderStore := certificateprovider .NewStore (dynamoClient )
96
+ lpaStoreResolvingService := lpastore .NewResolvingService (donorStore , lpaStoreClient )
86
97
87
98
if Tag == "" {
88
99
Tag = os .Getenv ("TAG" )
@@ -91,7 +102,7 @@ func handleRunSchedule(ctx context.Context) error {
91
102
client := cloudwatch .NewFromConfig (cfg )
92
103
metricsClient := telemetry .NewMetricsClient (client , Tag )
93
104
94
- runner := scheduled .NewRunner (logger , scheduledStore , donorStore , notifyClient , metricsClient , metricsEnabled )
105
+ runner := scheduled .NewRunner (logger , scheduledStore , donorStore , certificateProviderStore , lpaStoreResolvingService , notifyClient , eventClient , bundle , metricsClient , metricsEnabled )
95
106
96
107
if err = runner .Run (ctx ); err != nil {
97
108
logger .Error ("runner error" , slog .Any ("err" , err ))
@@ -154,8 +165,8 @@ func main() {
154
165
}
155
166
}(ctx )
156
167
157
- lambda .Start (otellambda .InstrumentHandler (handleRunSchedule , xrayconfig .WithRecommendedOptions (tp )... ))
168
+ awslambda .Start (otellambda .InstrumentHandler (handleRunSchedule , xrayconfig .WithRecommendedOptions (tp )... ))
158
169
} else {
159
- lambda .Start (handleRunSchedule )
170
+ awslambda .Start (handleRunSchedule )
160
171
}
161
172
}
0 commit comments