yyu-nim / yyu-nim.github.io

Production-ready Rust Libraries (PRL)
5 stars 0 forks source link

https://yyu-nim.github.io/actix/rust/actor/service/registry/2022/07/31/actix-registry-example.html #4

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

actix <6> - looking up addr from SystemRegistry | Your awesome title

Actix의 문서에는 중요한 기능들에 대한 설명이 상당 부분 빠져 있는데, 그 중 하나가 System Registry 이다. 소스 코드 로부터 이해해보면, Actor를 SystemService라는 형태로 생성할 수 있는 방법이 있음을 알게 되는데, 이 경우 다음의 두 가지 혜택이 자동으로 따라온다:

https://yyu-nim.github.io/actix/rust/actor/service/registry/2022/07/31/actix-registry-example.html

huijeong-kim commented 2 years ago

와~ 이제 댓글 달 수 있네요!! 😆👏

SystemService 는 명시적으로 start를 안 해 줘도 시작하는 걸까요 ?.? System 시작할 때 같이 시작하는 것 같은 느낌이네요 그리고 이름에서 주는 느낌 처럼 System 당 하나의 SystemService만 만들 수 있는 거겠죠..?

huijeong-kim commented 2 years ago

SystemService가 broker가 될 수 있을 것 같아 보니, actix-broker의 SystemBroker가 SystemService로 구현된 거였네요! ㅎㅎ

yyu-nim commented 2 years ago
<ActorType>::from_registry()

을 호출하면, 명시적으로 start()를 해주지 않아도 actor가 시작되는 것 같습니다. https://github.com/actix/actix/blob/master/actix/src/registry.rs#L259 에 의하면 start_service() 내에서 supervisor에 의해 자동 시작되는 것으로 이해하고 있습니다 ㅎ

생성할 수 있는 서비스 개수에 대해서는 타입당 하나인 것인것 같아요. https://github.com/actix/actix/blob/master/actix/src/registry.rs#L253에 의하면, ActorType으로 registry를 찾아봐서 없으면 생성후 서비스를 시작, 만약 이미 있었으면 그 주소를 바로 리턴해주는 것 같습니다. 가령, Service1::from_registry(), Service2::from_registry(), ..., 이런식으로 서비스를 여러개 등록할 수 있는 것 같습니다.

actix-broker 구현 방법도 한번 살펴봐야 겠네요! SystemService의 사용방법을 더 깊이 이해할 수 있을 것 같습니다 ㅎ

huijeong-kim commented 2 years ago

아하!! from_registry가 service 별로 있는거군요! 요 부분을 착각했었네요 ㅎㅎ