@@ -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" )
49
+ appPublicURL = os .Getenv ("APP_PUBLIC_URL" )
43
50
44
51
Tag string
45
52
@@ -81,8 +88,13 @@ func handleRunSchedule(ctx context.Context) error {
81
88
return err
82
89
}
83
90
84
- donorStore := donor .NewStore (dynamoClient , eventClient , logger , searchClient )
91
+ lambdaClient := lambda .New (cfg , v4 .NewSigner (), httpClient , time .Now )
92
+ lpaStoreClient := lpastore .New (lpaStoreBaseURL , secretsClient , lpaStoreSecretARN , lambdaClient )
93
+
85
94
scheduledStore := scheduled .NewStore (dynamoClient )
95
+ donorStore := donor .NewStore (dynamoClient , eventClient , logger , searchClient )
96
+ certificateProviderStore := certificateprovider .NewStore (dynamoClient )
97
+ lpaStoreResolvingService := lpastore .NewResolvingService (donorStore , lpaStoreClient )
86
98
87
99
if Tag == "" {
88
100
Tag = os .Getenv ("TAG" )
@@ -91,7 +103,19 @@ func handleRunSchedule(ctx context.Context) error {
91
103
client := cloudwatch .NewFromConfig (cfg )
92
104
metricsClient := telemetry .NewMetricsClient (client , Tag )
93
105
94
- runner := scheduled .NewRunner (logger , scheduledStore , donorStore , notifyClient , metricsClient , metricsEnabled )
106
+ runner := scheduled .NewRunner (
107
+ logger ,
108
+ scheduledStore ,
109
+ donorStore ,
110
+ certificateProviderStore ,
111
+ lpaStoreResolvingService ,
112
+ notifyClient ,
113
+ eventClient ,
114
+ bundle ,
115
+ metricsClient ,
116
+ metricsEnabled ,
117
+ appPublicURL ,
118
+ )
95
119
96
120
if err = runner .Run (ctx ); err != nil {
97
121
logger .Error ("runner error" , slog .Any ("err" , err ))
@@ -154,8 +178,8 @@ func main() {
154
178
}
155
179
}(ctx )
156
180
157
- lambda .Start (otellambda .InstrumentHandler (handleRunSchedule , xrayconfig .WithRecommendedOptions (tp )... ))
181
+ awslambda .Start (otellambda .InstrumentHandler (handleRunSchedule , xrayconfig .WithRecommendedOptions (tp )... ))
158
182
} else {
159
- lambda .Start (handleRunSchedule )
183
+ awslambda .Start (handleRunSchedule )
160
184
}
161
185
}
0 commit comments