Hello I'm trying to write an actor that polls github api to include in my app supervision tree.
The responses have a header telling me after how many seconds I can make a new request.
So in my mind it would work somehow like this:
fn notification_actor() {
actor.on_message(actor.new(Nil), fn(state, message) {
case message {
PollIntervalExpired -> {
let assert Ok(response) = todo as "the request"
let sleep_seconds =
list.key_find(response.headers, "x-poll-interval")
|> result.try(int.parse)
|> result.unwrap(60)
todo as "parse the response body"
// And now I'm not sure what to do...
// Here I was thinking of sending a message to myself
// after the given amount of seconds.
//
// I couldn't find an easy way to find a reference
// to self that I could send a message to
//
// But I'm getting a feeling this might not be how
// actors are meant to be used
actor.continue(Nil)
}
}
})
}
How should I go about this?


