Skip to content

Commit e6ba138

Browse files
committed
T-35: add proxy
1 parent 0acc5d6 commit e6ba138

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+168
-65
lines changed

pom.xml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
1616

1717
<!-- Spring -->
18-
<spring-aspects.version>6.0.2</spring-aspects.version>
18+
<spring-aspects.version>6.0.9</spring-aspects.version>
1919

2020
<!-- TelegramBots Spring Boot Starter -->
2121
<telegrambots-spring.version>0.26</telegrambots-spring.version>
2222

2323
<!-- Slack API -->
24-
<slack-api.version>1.27.1</slack-api.version>
24+
<slack-api.version>1.28.0</slack-api.version>
2525

2626
<!-- Google API -->
27-
<google-api-client.version>2.0.1</google-api-client.version>
27+
<google-api-client.version>2.2.0</google-api-client.version>
2828
<google-oauth-client-jetty.version>1.34.1</google-oauth-client-jetty.version>
29-
<google-sheets.version>v4-rev20220927-2.0.0</google-sheets.version>
29+
<google-sheets.version>v4-rev20230227-2.0.0</google-sheets.version>
3030

3131
<jackson-json.version>2.14.0</jackson-json.version>
3232
</properties>
@@ -49,6 +49,11 @@
4949
<artifactId>spring-cloud-starter-openfeign</artifactId>
5050
</dependency>
5151

52+
<dependency>
53+
<groupId>io.github.openfeign</groupId>
54+
<artifactId>feign-okhttp</artifactId>
55+
</dependency>
56+
5257
<dependency>
5358
<groupId>org.springframework.boot</groupId>
5459
<artifactId>spring-boot-starter-test</artifactId>
@@ -64,7 +69,7 @@
6469
<dependency>
6570
<groupId>com.squareup.okhttp3</groupId>
6671
<artifactId>okhttp</artifactId>
67-
<version>4.9.3</version>
72+
<version>4.10.0</version>
6873
</dependency>
6974

7075
<!-- Google Api -->

src/main/java/com/whiskels/notifier/App.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
package com.whiskels.notifier;
22

3+
import com.whiskels.notifier.slack.SlackConfig;
4+
import com.whiskels.notifier.telegram.TelegramConfig;
35
import org.springframework.boot.SpringApplication;
46
import org.springframework.boot.autoconfigure.SpringBootApplication;
57
import org.springframework.boot.context.properties.EnableConfigurationProperties;
68
import org.springframework.cloud.openfeign.EnableFeignClients;
9+
import org.springframework.context.annotation.ComponentScan;
10+
import org.springframework.context.annotation.FilterType;
11+
import org.springframework.context.annotation.Import;
712
import org.springframework.context.annotation.Profile;
813
import org.springframework.scheduling.annotation.EnableScheduling;
914

1015
@Profile("!test")
1116
@SpringBootApplication
17+
@ComponentScan(basePackages = "com.whiskels.notifier",
18+
excludeFilters = @ComponentScan.Filter(type = FilterType.REGEX, pattern = {"com.whiskels.notifier.telegram.*", "com.whiskels.notifier.slack.*"}))
19+
@Import({TelegramConfig.class, SlackConfig.class})
1220
@EnableScheduling
1321
@EnableConfigurationProperties
1422
@EnableFeignClients

src/main/java/com/whiskels/notifier/common/audit/AuditListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class AuditListener {
1515
private Clock clock;
1616

17-
@Autowired
17+
@Autowired //JPA spec requires @PrePersist classes to have no-args constructor
1818
public void setClock(Clock clock) {
1919
this.clock = clock;
2020
}

src/main/java/com/whiskels/notifier/common/datetime/ClockConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ClockConfiguration {
1515
private String timeZone;
1616

1717
@Bean
18-
public Clock defaultClock() {
18+
Clock defaultClock() {
1919
return Clock.system(ZoneId.of(timeZone));
2020
}
2121
}

src/main/java/com/whiskels/notifier/external/google/customer/_CustomerBirthdayInfoBeanConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class _CustomerBirthdayInfoBeanConfig {
2020
static final String PROPERTIES_PREFIX = "external.google.customer.birthday";
2121

2222
@Bean
23-
public Loader<CustomerBirthdayInfo> customerBirthdayInfoLoader(
23+
Loader<CustomerBirthdayInfo> customerBirthdayInfoLoader(
2424
Clock clock,
2525
GoogleSheetsReader spreadsheetLoader,
2626
CustomerBirthdaySpreadsheetProperties properties
@@ -29,7 +29,7 @@ public Loader<CustomerBirthdayInfo> customerBirthdayInfoLoader(
2929
}
3030

3131
@Bean
32-
public ReportSupplier<CustomerBirthdayInfoDto> customerBirthdayInfoDtoSupplier(Clock clock, Loader<CustomerBirthdayInfo> loader) {
32+
ReportSupplier<CustomerBirthdayInfoDto> customerBirthdayInfoDtoSupplier(Clock clock, Loader<CustomerBirthdayInfo> loader) {
3333
ReportSupplier<CustomerBirthdayInfo> reportSupplier = new MemoizingReportSupplier<>(loader, clock);
3434
return () -> reportSupplier.get().remap(CustomerBirthdayInfoDto::from);
3535
}

src/main/java/com/whiskels/notifier/external/json/currency/_CurrencyRateBeanConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
@Configuration
1717
class _CurrencyRateBeanConfig {
1818
@Bean
19-
public Loader<CurrencyRate> currencyRateLoader(CurrencyRateFeignClient currencyRateClient) {
20-
return new Loader<CurrencyRate>() {
19+
Loader<CurrencyRate> currencyRateLoader(CurrencyRateFeignClient currencyRateClient) {
20+
return new Loader<>() {
2121
@Override
2222
@Audit(loader = CURRENCY_RATE)
2323
public List<CurrencyRate> load() {
@@ -27,7 +27,7 @@ public List<CurrencyRate> load() {
2727
}
2828

2929
@Bean
30-
public ReportSupplier<CurrencyRate> currencyRateSupplier(Clock clock, Loader<CurrencyRate> loader) {
30+
ReportSupplier<CurrencyRate> currencyRateSupplier(Clock clock, Loader<CurrencyRate> loader) {
3131
return new MemoizingReportSupplier<>(loader, clock);
3232
}
3333
}

src/main/java/com/whiskels/notifier/external/json/debt/DebtFeignClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.whiskels.notifier.external.json.debt;
22

3+
import com.whiskels.notifier.external.proxy.FeignProxyConfig;
34
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
45
import org.springframework.cloud.openfeign.FeignClient;
56
import org.springframework.web.bind.annotation.RequestMapping;
@@ -8,7 +9,7 @@
89
import static org.springframework.web.bind.annotation.RequestMethod.GET;
910

1011

11-
@FeignClient(name = "debtClient", url = "${" + DEBT_URL + "}")
12+
@FeignClient(name = "debtClient", url = "${" + DEBT_URL + "}", configuration = FeignProxyConfig.class)
1213
@ConditionalOnProperty(DEBT_URL)
1314
interface DebtFeignClient {
1415
@RequestMapping(method = GET)

src/main/java/com/whiskels/notifier/external/json/debt/DebtLoader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717

1818
@RequiredArgsConstructor
1919
class DebtLoader implements Loader<Debt> {
20+
private static final int MIN_RUB_VALUE = 500;
21+
2022
private final ReportSupplier<CurrencyRate> rateReportSupplier;
2123
private final DebtFeignClient debtClient;
22-
private static final int MIN_RUB_VALUE = 500;
2324

2425
@Override
2526
@Audit(loader = DEBT)

src/main/java/com/whiskels/notifier/external/json/debt/_DebtConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ class _DebtConfig {
1818
static final String DEBT_URL = "external.customer.debt.url";
1919

2020
@Bean
21-
public Loader<Debt> debtLoader(ReportSupplier<CurrencyRate> currencyRateReportSupplier,
21+
Loader<Debt> debtLoader(ReportSupplier<CurrencyRate> currencyRateReportSupplier,
2222
DebtFeignClient debtClient) {
2323
return new DebtLoader(currencyRateReportSupplier, debtClient);
2424
}
2525

2626
@Bean
27-
public ReportSupplier<DebtDto> debtDtoSupplier(Clock clock, Loader<Debt> loader) {
27+
ReportSupplier<DebtDto> debtDtoSupplier(Clock clock, Loader<Debt> loader) {
2828
ReportSupplier<Debt> reportSupplier = new MemoizingReportSupplier<>(loader, clock);
2929
return () -> reportSupplier.get().remap(DebtDto::from);
3030
}

src/main/java/com/whiskels/notifier/external/json/employee/EmployeeFeignClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.whiskels.notifier.external.json.employee;
22

3+
import com.whiskels.notifier.external.proxy.FeignProxyConfig;
34
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
45
import org.springframework.cloud.openfeign.FeignClient;
56
import org.springframework.web.bind.annotation.RequestMapping;
@@ -10,7 +11,7 @@
1011
import static org.springframework.web.bind.annotation.RequestMethod.GET;
1112

1213

13-
@FeignClient(name = "employeeClient", url = "${" + EMPLOYEE_URL + "}")
14+
@FeignClient(name = "employeeClient", url = "${" + EMPLOYEE_URL + "}", configuration = FeignProxyConfig.class)
1415
@ConditionalOnProperty(EMPLOYEE_URL)
1516
interface EmployeeFeignClient {
1617
@RequestMapping(method = GET)

0 commit comments

Comments
 (0)