Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

https://yyu-nim.github.io/actix/rust/recipient/actor/2022/07/31/actix-recipient-usage.html #3

Open
utterances-bot opened this issue Jul 31, 2022 · 5 comments

Comments

@utterances-bot
Copy link

actix <5> - recipient vs. addr | Your awesome title

Actix에서 actor에게 메시지를 보낼 때, 두 종류의 addressing을 사용할 수 있다. 한 가지는 Addr 이고, 다른 한 가지는 Recipient 이다. 둘 모두 do_send, send 를 사용하여 메시지를 보내기 때문에 유사해 보이는데, 결정적인 차이는, Addr의 generic type "T"는 actor type이 들어가고, Recipient의 generic t

https://yyu-nim.github.io/actix/rust/recipient/actor/2022/07/31/actix-recipient-usage.html

Copy link
Owner

yyu-nim commented Jul 31, 2022

코멘트 달 수 있습니다!

Copy link

dhihm commented Aug 6, 2022

예제 보다가 궁금한 점이 있는데요, system 안에서 actor의 동작 (block_on (async)) 을 수행하면, 이 안에 있는 코드들이 한 번 끝까지 다 수행 된 후에, 이 들이 보낸 메시지들이 각 actor에서 수행되는 것 같은데, 그럼 반복적인 코드 수행은 어떻게 하는 건가요? 추가적인 코드 수행.

예를 들면, 이 예제에서 change path와 io request를 계속해서 수행하고 싶다면요.

Copy link
Owner

yyu-nim commented Aug 6, 2022

일단 sys.run()에서 blocking을 하고 있기 때문에, actor 들은 살아 있을 것입니다. 따라서 이벤트/메시지를 만들어서 actor들에게 전달해 주는 형태가 되어야 할 것 같아요. 예를 들면,

  1. ctx를 위 예제에서는 사용하지 않지만, actor가 주기적인 작업이나 delayed execution을 하여 스스로 이벤트를 만드는 방법이 있고 (https://github.com/actix/actix/blob/master/actix/examples/weak_addr.rs#L52)
  2. channel 의 rx 부분을 actor 에게 건네주고 그걸 polling하거나 blocking wait 하도록 해서 non-actor와 actor 를 연결해주는 방법,
  3. grpc / http server 의 request handling 시 점에 actor address로 message를 보내주는 방법

정도가 일단 생각납니다 ㅎ 각각에 대해서 나중에 예제 코드도 생각해봐야 할 것 같습니다. 이 중 1번이 제일 단순할 수 있을 것 같은데, TestDriver 라는 actor를 하나 만들어서 무한 loop을 돌면서 MultipathActor에게 change path랑 io request를 계속 보내줄 수 있을 것 같아요

@dhihm
Copy link

dhihm commented Aug 6, 2022

test driver 랑 생성된 다른 actor들이 계속 ping pong 할 수 있게 해보고 싶은데 아직 어렵네요 ㅋ loop를 쓰니까 그 loop를 탈출하기 전까지 다른 actor들이 메세지 fetch를 아예 못하고.. 알려주신 링크로 일단 시도해 보겠습니다 🙉

@dhihm
Copy link

dhihm commented Aug 6, 2022

1번에 공유해주신 예제가 딱 제가 원하던 거였네요. 많은 도움이 됐습니다. 통곡의 벽을 하나 넘었네요 ㅋㅋ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants