Make the repo a gen_server

This helps us make sure we only have one thread accessing a particular
repo at a time and hopefully help us be more in line with usual erlang
practices.