Data warehouse in the actor's system

I am working on an ack actor based event handling pipeline. I have 3 members for each stage in the pipeline: FilterWorker, EnrichWorker, and ProcessWorker; plus a supervising actor who ensures that events are sent from one step from the pipeline to the next.

During the enrichment phase, I might need to query an external database to get more data, or even create new data that I want to store. For example, the enrichment stage of a web analytics system may want to enrich a click event by a user who clicked and stored that user information in a database.

With this example in mind, I see the following options:

1. Use a singleton; for example the UserStore, which keeps in memory all users collected so far and stores them in the database from time to time; has all the logic to get users who are not yet in memory. Doesn't seem to use a singleton in the actor system (?).

  1. Use a store actor. Use the tell command to add a new user and ask for it.

Is there a better template for this?

Thank!

+3


source to share


1 answer


Not to leave this unanswered, I went with my second option, and johanandren's suggestion for the Actor to populate the datastore role. Works well!



+1


source







All Articles