Implement AutoShardedClient for transparent sharding.

This allows people to run their >2,500 guild bot in a single process
without the headaches of IPC/RPC or much difficulty.
This commit is contained in:
Rapptz
2017-01-07 21:55:47 -05:00
parent d54d7f7ac0
commit 20041ea756
9 changed files with 341 additions and 31 deletions

View File

@ -588,5 +588,14 @@ class HTTPClient:
raise GatewayNotFound() from e
return data.get('url') + '?encoding=json&v=6'
@asyncio.coroutine
def get_bot_gateway(self):
try:
data = yield from self.get(self.GATEWAY + '/bot', bucket=_func_())
except HTTPException as e:
raise GatewayNotFound() from e
else:
return data['shards'], data['url'] + '?encoding=json&v=6'
def get_user_info(self, user_id):
return self.get('{0.USERS}/{1}'.format(self, user_id), bucket=_func_())