Skip to content

Commit 05cf5c3

Browse files
committedApr 25, 2024
docs: Read.md 문서 작성
1 parent 1acbb55 commit 05cf5c3

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed
 

‎README.md

+72
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,75 @@
77
<br/>
88

99
## 🛠️ 사용 SW
10+
11+
---
12+
13+
![slidingwindowlog.png](slidingwindowlog.png)
14+
15+
<br/>
16+
17+
## 🏢 아키텍처 구조
18+
19+
---
20+
21+
22+
```
23+
├── common 패키지
24+
│ └── config 패키지
25+
│ └── RedisConfig.class
26+
27+
│ └── dto 패키지
28+
│ └── ExceptionResponse.class
29+
│ └── exception 패키지
30+
│ └── BusinessException.class
31+
│ └── CommonException.class
32+
│ └── CommonExceptionCode.enum
33+
│ └── ExceptionCode.interface
34+
│ └── GlobalExceptionHandler.class
35+
36+
├── Controller 패키지
37+
│ └── SlidingWindowLogController.class
38+
39+
├── dto 패키지
40+
│ └── response 패키지
41+
│ └── SlidingWindowLogProfileResponse.class
42+
│ └── SlidingWindowLogResponse.class
43+
44+
├── exception 패키지
45+
│ └── RateException.class
46+
│ └── RateLimitExceededException.enum
47+
48+
├── service 패키지
49+
│ └── SlidingWindowLogService.class
50+
51+
└── SlidingWindowLogApplication.class
52+
53+
```
54+
55+
<br/>
56+
57+
## ✏️ API 설명
58+
59+
---
60+
61+
### 1️⃣ 이동 윈도 로깅 생성 API
62+
- 이동 윈도 로깅 생성 API는 이동 윈도 로깅 알고리즘을 구현한 API입니다.
63+
- 이동 윈도 로깅 생성 API는 요청을 받으면 Redis에 이동 윈도 카운터를 생성하고 요청 횟수를 증가시킵니다.
64+
- - 각 카운터는 고유한 **윈도 기간(60초)** 동안 유효하며, 이 기간 내의 요청 수를 카운트합니다.
65+
- 요청 수가 **고정된 최대 요청 허용 수(1000회)** 를 초과하면, 요청은 제한됩니다.
66+
- 요청이 성공적으로 처리되면, 현재 요청 카운터의 키와 요청 수를 반환합니다.
67+
68+
``` Http
69+
POST /sliding-window-log
70+
```
71+
72+
<br/>
73+
74+
### 2️⃣ 이동 윈도 로깅 조회 API
75+
- 생성된 이동 윈도 로깅의 정보를 조회하는 API입니다.
76+
- **모든 유효한 이동 윈도 로깅의 키와 해당 키의 요청 수를 조회할 수 있습니다.**
77+
- **Redis에서 이동 윈도 로깅 카운터를 스캔하여, 각 카운터의 현재 요청 수와 함께 반환**합니다.
78+
79+
``` Http
80+
GET /sliding-window-log
81+
```

‎slidingwindowlog.png

30.8 KB
Loading

‎src/main/java/com/systemdesign/slidingwindowlog/common/common/RedisConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class RedisConfig {
1616
public ReactiveRedisTemplate<String, Object> reactiveRedisTemplate(ReactiveRedisConnectionFactory connectionFactory) {
1717
ObjectMapper objectMapper = new ObjectMapper();
1818
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
19-
objectMapper.activateDefaultTyping(objectMapper.getPolymorphicTypeValidator(), ObjectMapper.DefaultTyping.EVERYTHING, JsonTypeInfo.As.PROPERTY); // 모든 객체 타입에 대한 정보를 포함
19+
objectMapper.activateDefaultTyping(objectMapper.getPolymorphicTypeValidator(), ObjectMapper.DefaultTyping.EVERYTHING, JsonTypeInfo.As.PROPERTY);
2020

2121
RedisSerializer<Object> redisSerializer = new GenericJackson2JsonRedisSerializer(objectMapper);
2222

0 commit comments

Comments
 (0)
Please sign in to comment.