2019년 11월 4일 월요일

libp2p - Publish/Subscribe 를 읽고

https://docs.libp2p.io/concepts/publish-subscribe/

- Discovery

Distributed hash tables
Local network broadcasts
Exchanging peer lists with existing peers
Centralized trackers or rendezvous points
Lists of bootstrap peers

peer와의 연결에 full-message와 metadata-only 방식이 있다. full-message peering은 메시지를 주고 받을 때 사용하는 연결로서, 최대 연결 가능한 peer의 수를 제한(6정도)하여 연결을 맺는다. metadata-only peering은 full-message로 연결되어 있지 않은 peer들을 더 많이 연결을 맺어 관련 여러 정보들을 주고 받는다.(예를 들면 '난 이런 토픽들에 subscribe하고 있다', '난 이런 토픽에 unscribe 한다.' 등등)

peer는 메시지를 받으면 full-message로 연결된 peer에 메시지를 포워딩한다. 또한, 매 1초마다 metadata-only로 연결된 peer들 중 6개를 랜덤으로 골라서 최근에 받은 메시지를 보낸다. 이렇게 서로서로 받은 메시지가 무었인지를 주고 받음으로서 내가 어떤 메시지를 받았는지 못 받았는지를 확인하고 이에 따라 full-message로 연결될 peer를 조정한다.(기존에 full-message로 연결된 peer를 metadata-only로 조정하고, metadata-only로 연결된 peer를 full-message로 바꾼다던지)

내가 subscribe 하고 있지 않은 topic에도 메시지를 보낼 수 있다. 이를 Fan-out이라 한다. 

댓글 없음:

댓글 쓰기

Building asynchronous views in SwiftUI 정리

Handling loading states within SwiftUI views self loading views View model 사용하기 Combine을 사용한 AnyPublisher Making SwiftUI views refreshable r...