#Function run periodically on an actor

1 messages · Page 1 of 1 (latest)

hollow swallow
#

Hello, I was wondering if there was a way to run a function on an actor periodically (say every 30 seconds)? During this 30 second time between running the function I would like the actor to still be able to process received messages

errant tusk
#

You can do a process.send_aftermessage sending it to the actor itself.

fn loop(
  state: State,
  msg: msg.ClientRequest(String),
) -> actor.Next(State, msg.ClientRequest(String)) {
  case msg {
    msg.SelfReq -> {
      // Send request to service itself every 30 s
      process.send_after(state.my_subject, 30_000, msg.SelfReq)
tacit leaf
#

but yeah same concept as karlson mentioned

hollow swallow
#

Thank you!