Giter Club home page Giter Club logo

al-1s's Introduction

Introduction

FE Developer always chaising fun stuffs. Followings are my interests

  • First order logic and SAT solver
  • Mathematical optimization
  • Functional programming
  • Heavy type inference using TypeScript like this one

I'm the original designer and author of the project dxf-json (Not dxf-parser). Currently I'm participating in that project as sub-maintainer.

I love writing small snippets which was targeted for mathematical things. If you're interested, please visit gist page.

Useful Snippets

내가 자주 쓰는 것들 모음집

Utilities

React

Algorithm & Data Structures

Math

al-1s's People

Contributors

phryxia avatar ynifamily3 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

al-1s's Issues

번들링 필요 의문성 제기

  • 한 파일로 번들링할 필요가 없음. 오히려 빌드 타임만 늘어남.
  • 의존 라이브러리 번들링은 더더욱 필요 없음. 라이브러리 내부에 ambiguous dependency가 있을 수 있어 에러가 발생하기도 하고, 속도도 더욱 느려짐.
  • node로 바로 실행할 수 있을 정도로만 트랜스파일 하는 것이 좋을 것 같다.

봇 서버 클러스터링을 하기 위해 필요한 것들

텔레그램 서버에 쌓인 메시지 큐를 가져와서 분배하는 Consumer 서버가 있어야 함. 폴링을 쓰든 웹훅을 쓰든 이 작업을 해주는 서버는 하나만 있어도 충분하고, 하나만 있어야 함.

Consumer 서버는 메시지를 적절히 분배하고 이것에 특화된 것이 카프카라는 툴이라고 함.

고려해 볼 점

카프카로 메시지를 적절히 분배한 다음, 각각의 봇 서버에서 카프카에서 받은 메시지를 처리하면 된다.

그런데 한 가지 문제가 있다.

프로덕션에선 스케일업이 가능하도록 카프카 생태계를 구성해야겠지만, 개발 환경에서는 최대한 외부 인프라 사용을 하지 않는 방식이 가장 적합하다. 그러나 기존 node용 Telegram 라이브러리는 텔레그램 서버에서 직접 데이터를 받아오므로, 라이브러리를 뜯지 않는 이상 동일 소스를 유지하면서 환경 변화에 대응하기가 어렵다.

잠재적 방안

  • 스케일업 할 수 있는 개별 인스턴스에는 라이브러리에서 '타입'만 참조하고, 실제 메시지를 수신하는 것을 API로 추상화하여 분리한다.
  • Consumer 서버에서 라이브러리의 클라이언트(new TelegramBot)를 가동하여 IO를 담당하고, 분산은 각 인스턴스 서버의 개별 API를 호출한다.
  • 모든 과정은 비동기로 이루어져야 한다.

ex) Consumer가 메시지큐에서 fetch -> 1번 서버의 processMessage API호출 -> 받았던 Telegram Message를 그대로 전달 -> 1번 서버가 내부에서 로직 처리 -> Consumer 서버의 sendMessage API 호출 -> Consumer 서버가 Telegram.send로 텔레그램 서버에 전달

우선순위

공수가 상당히 많이 들어갈 것 같습니다. 기능 개발이 먼저라서 이런 devops는 나중에 스케일업 단계에서 생각해봅시다.

import 컨벤션에 관하여

아무생각 없이 인텔리센스 자동 import에 의존하면, 의도치 않은 순환참조가 생길 수 있다.

따라서 다음과 같은 컨벤션을 제안한다.

기본원리

  • 최단경로를 사용하되
  • 자신을 포함하는 index.tsimport하지 않는다.

구체적 사례

1. 자신과 동일 위계 & 상위 index.ts는 절대 import하지 않는다.

dir
┣ index.ts
┣ target.ts
└ current.ts

import from './target'
import from '.'

2. import 대상이 자신이 속한 디렉토리 아래에 있다면, 상대 경로를 사용하되 반드시 최단 경로를 사용한다.

d0
┣ d1
│ ┣ index.ts
│ └ target.ts
┣ index.ts
└ current.ts

import from './d1'
import from './d1/target'
import from '.'

3. import 대상이 자신이 속한 디렉토리 밖에 있다면,

  • 깊이 차가 2 이하이면 상대경로
  • 초과면 절대경로를 사용하며
  • 최단거리를 채택하되
  • index.ts가 공통조상이면 한 뎁스 더 들어간다
@src
┣ d1
│ ┣ d2
│ │ ┣ d3
│ │ │ ┣ index.ts
│ │ │ └ current.ts
│ │ ┣ index.ts
│ │ └ t1.ts
│ ┣ index.ts
│ └ t2.ts
┣ index.ts
┣ t3.ts
└ d4
  ┣ index.ts
  └ t4.ts

import from '../t1'
import from '../../t2'
import from '../../../t3'
import from '@src/t3'
import from '@src/d4/t4'
import from '@src/d4'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.