Defining services as actor vs struct

Why do some code chapters (.e.g. 10) define the FetchAnimalsService and AnimalStoreService as actors, and other chapters (e.g. 5) define them as structs?

For example, in the chapter 5 folder, I found this commit replacing actor with struct.

I understand what an actor is, and how it’s used to prevent multiple threads from accessing data, but these service types don’t seem like they need to protect any data, so I’m curious why you would ever want to define them as actors. Thanks!

1 Like

Hi @beeeph

Actors were used more as a educational point here. To exemplify how they could be used in this context. But in this specific application, like you said, they’re not protecting any data so they’re not needed.

1 Like