Initial extraction of sharding code from internal service.