Skip to content

Commit

Permalink
dataloader 간략
Browse files Browse the repository at this point in the history
  • Loading branch information
deptno committed Feb 3, 2024
1 parent 953a3f7 commit 57a8914
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
21 changes: 18 additions & 3 deletions about-me.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

### 2019-06 ~ 2021-05: 알스퀘어, 팀장
- 사내 back-office 개발, 프론트엔드로 시작하여 백엔드까지 전체 타입스크립트 + 노드로 마이그레이션
- [[csharp]] -> [[node]] + [[graphql]] 마이그레이션
- [[csharp]] -> [[node]] + [[graphql]] + [[dataloader]] 마이그레이션
- elk + beat 기반의 [[log]] 모니터링 시스템 생성
- [[kubernetes]] + [[helm]] 기반의 배포환경 구성

Expand Down Expand Up @@ -52,13 +52,13 @@
### 공인중개사 문제은행
- 시험문제 -> [[markdown]] 변환 이후 커스텀 렌더러를 통해서 모든 렌더링을 구현
- [[serverless]] 서비스들로만 구현 + [[dynamodb]], [[lambda]]+edge([[seo]]), cognito, iot(websocket)
- [[nextjs]], graphql
- [[nextjs]], [[graphql]]
+ **서비스** https://googit.co

### 구깃
- 이력관리 + SNS link 를 통한 프로필, 이력서 제공 서비스
- [[serverless]] 서비스들로만 구현 + [[dynamodb]], [[lambda]]+edge([[seo]]), cognito
- [[nextjs]], graphql
- [[nextjs]], [[graphql]]
+ **서비스** https://googit.io
+ **개발 기록** https://googit.io/post/ap-northeast-2:c03f8bf0-992e-48a8-93b6-15787a0fc96f/public/googit/

Expand All @@ -76,6 +76,21 @@
+ **서비스** https://deptno.github.io/map-subway-storage
+ **깃허브** https://github.com/deptno/map-subway-storage

# 개인 라이브러리
### dataloader-toolbox
- session 당 [[dataloader]] 래퍼 함수의 인터스턴스 유지하기 위한 session
- [[sql]] `IN` operator 가 함수 순서보장을 안하므로 서버에서 정렬하기 위한 sorter
+ **깃허브** https://github.com/deptno/dataloader-toolbox

### pg-toolbox
- 쿼리와 변수를 함께 보기위한 *tagged template literals* 기반한 sql 생성기
+ **깃허브** https://github.com/deptno/pg-toolbox/tree/master/packages/asql

### dataloader-toolbox
- session 당 [[dataloader]] 래퍼 함수의 인터스턴스 유지하기 위한 session
- [[sql]] `IN` operator 가 함수 순서보장을 안하므로 서버에서 정렬하기 위한 sorter
+ **깃허브** https://github.com/deptno/dataloader-toolbox

# 개인 설정
### .config
- [[terminal]] 사용을 위한 개인 설정
Expand Down
25 changes: 25 additions & 0 deletions dataloader.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# dataloader

## 코어 피쳐
- 배치
- 각각의 요청을 모아서 nexttick 타이밍에, 배치 요청을 함수를 호출하여 한번에 데이터를 가져온다
- 캐싱
- 요청에 대한 값을 캐싱하여 디비에 두번 쿼리하지 않는다

## 사용을 위해 라이브러리
+ **깃허브** https://github.com/deptno/dataloader-toolbox

### 설명
> 사용했던 dataloader-toolbox 코드를 기준으로 의미를 역추적하여 그럴것이다라는 추론으로 빠르게 정리
- 요청당 dataloader session 을 생성
- session 은 `WeakMap` 형태, function 주소를 key 값으로 가짐
- database query 요청 함수에 대해서 dataloader **wrapper** 를 생성하고 session 에 저장
- original 함수는 배치 처리를 위한 `T[]` 인자를 받는 함수
- **wrapper**`.load` 메소드를 통해서 `T` 를 인자로 받는 함수
- 해당 함수를 resolver 의 여러 곳에서 호출하게될 수 있는데 이때 마다 wrapper 를 획득하여 호출(캐싱처리)
- 해당 요청이 모여 nexttick 에 배치 처리를 하게되면서 실제 함수인 original 함수가 호출
- 응답이 각 **wrapper** 의 호출부였던 `.load(T)` 에 응답 분배됨

## link
- [[graphql]]
6 changes: 6 additions & 0 deletions graphql.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# graphql

오래된 기억 정리를 위해 파일 생성

## link
- [[dataloader]]

0 comments on commit 57a8914

Please sign in to comment.