Fork me on GitHub
#rethinkdb
<
2017-02-15
kasuko16:02:07

Hey guys, I was looking into rethinkdb because I would like to design a reactive database on the server for a multiplayer game I am designing. My thought was to do this in a similar way to re-frame’s subscriptions where a player will connect to the server and subscribe to game data they need (eg character stats, skills etc) and then those will automatically be resent to the client when they change server side.

kasuko16:02:55

I am a little fuzzy how/if I can achieve this. I see in the clojure wrapper there is a core.async functionality but would that mean that every client that connects and every query they make will create a thread? Would that be limiting?

nha16:02:58

@kasuko I think core.async uses a shared thread pool.

kasuko16:02:08

Alright, I will look into that. Though does that mean that I may run into queries blocking other queries?

nha16:02:24

Maybe. Although if that happens.. well that’s a good problem to have 🙂

kasuko16:02:16

I was worried about say 8 players creating a query for there skills which only change slowly. Then a 9th player subscribing to their stats (like HP) which may change often. But since the first 8 players are using the threads to wait for their skills to change they block the 9th player from seeing their HP update. However it looks like if I stick to go blocks that makes a IOC thread which parks the thread if it’s waiting for a message and that means that 8 queries that have actually returned something can run at a time, and since a query returning would most likely just result in a message down a websocket I think I’ll be okay