Skip to content

Commit

Permalink
Allow Reporting endpoints more time to respond
Browse files Browse the repository at this point in the history
We’re finding these endpoints can take more than 30 seconds to respond. This is understandable as the data they’re loading on demand is big.

A longer term solution will be to move this reports from being on demand and to being generated in advance. This will take more time that we have left to do at this point so we try to find a compromise.

The timeout of RestClient doesn’t seem configurable from the reports controller. This might have be a cleaner option rather than repeating the API config.
  • Loading branch information
tahb committed Nov 13, 2023
1 parent dcfbaa2 commit 78dbfa4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ export default {
agent: new AgentConfig(Number(get('COMMUNITY_ACCOMMODATION_API_TIMEOUT_RESPONSE', 10000))),
serviceName: 'temporary-accommodation',
},
approvedPremisesReports: {
url: get('APPROVED_PREMISES_API_URL', 'http://localhost:9092', requiredInProduction),
timeout: {
response: 50000,
deadline: 50000,
},
agent: new AgentConfig(Number(get('COMMUNITY_ACCOMMODATION_API_TIMEOUT_RESPONSE', 40000))),
serviceName: 'temporary-accommodation',
},
audit: {
region: get('AUDIT_SQS_REGION', 'eu-west-2'),
queueUrl: get('AUDIT_SQS_QUEUE_URL', ''),
Expand Down
4 changes: 2 additions & 2 deletions server/data/reportClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ describe('ReportClient', () => {
const callConfig = { token: 'some-token' } as CallConfig

beforeEach(() => {
config.apis.approvedPremises.url = 'http://localhost:8080'
fakeApprovedPremisesApi = nock(config.apis.approvedPremises.url)
config.apis.approvedPremisesReports.url = 'http://localhost:8080'
fakeApprovedPremisesApi = nock(config.apis.approvedPremisesReports.url)
reportClient = new ReportClient(callConfig)
})

Expand Down
2 changes: 1 addition & 1 deletion server/data/reportClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default class ReportClient {
restClient: RestClient

constructor(callConfig: CallConfig) {
this.restClient = new RestClient('personClient', config.apis.approvedPremises as ApiConfig, callConfig)
this.restClient = new RestClient('personClient', config.apis.approvedPremisesReports as ApiConfig, callConfig)
}

async bookings(response: Response, filename: string, month: string, year: string): Promise<void> {
Expand Down

0 comments on commit 78dbfa4

Please sign in to comment.