This repository was archived by the owner on Mar 15, 2025. It is now read-only.
블로그 변경사항 수집기 구조 (생각) #18
Closed
kimminkyeu
started this conversation in
메모장
Replies: 2 comments 2 replies
-
첫 번째 문제 (scheduler)
두 번째 문제 (scrapper)
구현 중인 RSS 고민저도 어떻게 추상화할 지 고민하고 있는 중이었는데 같이 고민해보면 좋을 것 같습니다.
@Service
@RequiredArgsConstructor
public class RssService {
private final RestTemplate restTemplate;
// enum으로 분리
private static final String BAELDUNG_URL = "https://www.baeldung.com/feed";
private static final String TOSS_URL = "https://toss.tech/rss.xml";
private static final String WOOWA_URL = "https://techblog.woowahan.com/feed/";
private static final String KAKAO_URL = "https://tech.kakao.com/posts/feed";
private static final String DAANGN_URL = "https://medium.com/feed/daangn";
private static final String LINE_URL = "https://techblog.lycorp.co.jp/ko/feed/index.xml";
public RssResponse.Channel getRssByBaeldung() {
RssResponse rss = restTemplate.getForObject(BAELDUNG_URL, RssResponse.class);
return Objects.requireNonNull(rss).getChannel();
}
public RssResponse.Channel getRssByToss() {
RssResponse rss = restTemplate.getForObject(TOSS_URL, RssResponse.class);
return Objects.requireNonNull(rss).getChannel();
}
public RssResponse.Channel getRssByWoowa() {
RssResponse rss = restTemplate.getForObject(WOOWA_URL, RssResponse.class);
return Objects.requireNonNull(rss).getChannel();
}
public RssResponse.Channel getRssByKakao() {
RssResponse rss = restTemplate.getForObject(KAKAO_URL, RssResponse.class);
return Objects.requireNonNull(rss).getChannel();
}
public RssResponse.Channel getRssByDaangn() {
RssResponse rss = restTemplate.getForObject(DAANGN_URL, RssResponse.class);
return Objects.requireNonNull(rss).getChannel();
}
public RssResponse.Channel getRssByLine() {
RssResponse rss = restTemplate.getForObject(LINE_URL, RssResponse.class);
return Objects.requireNonNull(rss).getChannel();
}
}
@Getter
public class RssResponse {
@JacksonXmlProperty(localName = "channel")
private Channel channel;
@Getter
public static class Channel {
@JacksonXmlElementWrapper(useWrapping = false)
@JacksonXmlProperty(localName = "item")
private List<Item> item;
}
@Getter
@ToString
public static class Item {
@JacksonXmlProperty(localName = "title")
private String title;
@JacksonXmlProperty(localName = "link")
private String link;
@JacksonXmlProperty(localName = "pubDate")
private String pubDate;
@JacksonXmlProperty(localName = "creator")
private String creator;
@JacksonXmlElementWrapper(useWrapping = false)
@JacksonXmlProperty(localName = "category")
private List<String> category;
}
}
"item": [
{
"title": "로봇 ML 모델의 경량화 1부: 훈련 후 양자화",
"link": "https://techblog.woowahan.com/18980/",
"pubDate": "Thu, 22 Aug 2024 06:15:14 +0000",
"creator": "박준수",
"category": [
"Deep Learning",
"Machine Learning",
"Robotics"
]
},
{
"title": "[다시 보기] 8월 우아한테크세미나: 생성AI로 똑똑하게 일하는 법",
"link": "https://techblog.woowahan.com/19317/",
"pubDate": "Thu, 22 Aug 2024 05:18:51 +0000",
"creator": "우아한형제들 DevRel",
"category": [
"-",
"우아한테크세미나"
]
},
|
Beta Was this translation helpful? Give feedback.
2 replies
-
기획 변경으로 인한 디스커션 종료 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
수집기 구조 설계안
@sangwonsheep @Gyaak
어떻게 짜면 구조가 쉽고 합치기 좋을지... 고민이 됩니다.
for문
)for문
)한 기능에 반복문이 통으로 묶이면 안될 것 같아요.
그래서 스케쥴러 구현할 때, 게시물 하나 하나에 대한 변환 과정을
함수로 분리해서 연결(
체이닝 호출
)하면 어떨까 싶어요.가볍게 초안처럼 그려본 거니 의견 주십쇼!!
크게 3가지 인터페이스로 분리할 수 있을 듯 합니다.
interface BlogScouter
수색대interface ArticleScrapper
수집가없는 데이터 필드는 null로 입력합니다.
interface DataFormalizer
형식 맞추미날짜: yyyy/mm/dd 로 매핑
토픽: 서비스에서 정의한 Topic으로 매핑
위 구조를 잡고, 나중에 for문 처리 로직을 한 함수에서 묶어주면 낫지 않을까 싶은데...
내일 얘기해보시죠...
멀티스레드
Beta Was this translation helpful? Give feedback.
All reactions