this post was submitted on 24 Sep 2021
1 points (100.0% liked)

Thai Rust Programming Language Community

47 readers
1 users here now

founded 3 years ago
MODERATORS
 

Actix มี supervisor ที่ช่วย restart actor ใต้บังคับ แต่บางทีมันก็ไม่ restart 😹

เท่าที่ทราบบางอย่างต้องส่ง Die (message) ไปให้ actor เวลามีอะไรพัง actor ต้อง implement ตัว handle Die message handler ใน handler ต้องเรียก ctx.stop (context stop) เมื่อ "Actor::stopping(...) == Running::Stop" poll function จะคืนค่า Poll::Ready จากนั้น supervisor ก็จะไปสั่ง restart ได้

ในกรณีของผมพวกนี้ทำงานไม่ได้เพราะสองอย่างคือ

  1. Actor หยุดแบบไม่ได้เรียก stopped function ดังนั้นทำให้ actor ไม่มีโอกาสได้ handle Die message เลย

  2. Actor ใช้ CPU เพราะเกิดกรณีที่ผิดพลาด ดังนั้น poll function ก็โดน block ไปเลย ทำให้ actor ไม่สามารถ handle Die message.

ผมแก้กรณีแรกโดยเรียก tokio::time::sleep และกรณีที่สองโดยเรียก break ออกจาก loop

ปล. ผมไม่มั่นใจเรื่องที่เขียนเลย ถ้าผมเข้าใจอะไรผิดก็ให้ชี้แนะด้วยครับ

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here