logger.info("Using StatsD server: ".format(config.STATSD_SERVER)) # Make sure we can shutdown gracefully signal.signal(signal.SIGTERM, signal_handler) signal.signal(signal.SIGINT, signal_handler) pool_fut = asyncio. async (server.db.connect(host=DB_SERVER, port=int(DB_PORT), user=DB_LOGIN, password=DB_PASSWORD, maxsize=10, db=DB_NAME, loop=loop)) db_pool = loop.run_until_complete(pool_fut) players_online = PlayerService(db_pool) api_accessor = ApiAccessor() event_service = EventService(api_accessor) achievement_service = AchievementService(api_accessor) game_stats_service = GameStatsService(event_service, achievement_service) natpacket_server = NatPacketServer( addresses=config.LOBBY_NAT_ADDRESSES, loop=loop) loop.run_until_complete(natpacket_server.listen()) server.NatPacketServer.instance = natpacket_server games = GameService(players_online, game_stats_service) matchmaker_queue = MatchmakerQueue('ladder1v1', players_online, games) players_online.ladder_queue = matchmaker_queue
def mock_players(mock_db_pool): return mock.create_autospec(PlayerService(mock_db_pool))
async def player_service(database): player_service = PlayerService(database) await player_service.initialize() return player_service
logger.info("Using StatsD server: ".format(config.STATSD_SERVER)) # Make sure we can shutdown gracefully signal.signal(signal.SIGTERM, signal_handler) signal.signal(signal.SIGINT, signal_handler) pool_fut = asyncio.async(server.db.connect(host=DB_SERVER, port=int(DB_PORT), user=DB_LOGIN, password=DB_PASSWORD, maxsize=10, db=DB_NAME, loop=loop)) db_pool = loop.run_until_complete(pool_fut) players_online = PlayerService(db_pool) api_accessor = ApiAccessor() event_service = EventService(api_accessor) achievement_service = AchievementService(api_accessor) game_stats_service = GameStatsService(event_service, achievement_service) natpacket_server = NatPacketServer(addresses=config.LOBBY_NAT_ADDRESSES, loop=loop) loop.run_until_complete(natpacket_server.listen()) server.NatPacketServer.instance = natpacket_server games = GameService(players_online, game_stats_service) matchmaker_queue = MatchmakerQueue('ladder1v1', players_online, games) players_online.ladder_queue = matchmaker_queue ctrl_server = loop.run_until_complete(server.run_control_server(loop, players_online, games))
logger.info("Using StatsD server: ".format(config.STATSD_SERVER)) # Make sure we can shutdown gracefully signal.signal(signal.SIGTERM, signal_handler) signal.signal(signal.SIGINT, signal_handler) pool_fut = asyncio.async(server.db.connect(host=DB_SERVER, port=int(DB_PORT), user=DB_LOGIN, password=DB_PASSWORD, maxsize=10, db=DB_NAME, loop=loop)) db_pool = loop.run_until_complete(pool_fut) players_online = PlayerService(db_pool) api_accessor = None if config.USE_API: api_accessor = ApiAccessor() event_service = EventService(api_accessor) achievement_service = AchievementService(api_accessor) game_stats_service = GameStatsService(event_service, achievement_service) natpacket_server = NatPacketServer(addresses=config.LOBBY_NAT_ADDRESSES, loop=loop) loop.run_until_complete(natpacket_server.listen()) server.NatPacketServer.instance = natpacket_server games = GameService(players_online, game_stats_service) matchmaker_queue = MatchmakerQueue('ladder1v1', players_online, games)
def player_service(loop, players): return PlayerService()
def mock_players(db_engine): return mock.create_autospec(PlayerService())
# Make sure we can shutdown gracefully signal.signal(signal.SIGTERM, signal_handler) signal.signal(signal.SIGINT, signal_handler) engine_fut = asyncio.ensure_future( server.db.connect_engine(host=DB_SERVER, port=int(DB_PORT), user=DB_LOGIN, password=DB_PASSWORD, maxsize=10, db=DB_NAME, loop=loop)) engine = loop.run_until_complete(engine_fut) players_online = PlayerService() twilio_nts = None if TWILIO_ACCOUNT_SID: twilio_nts = TwilioNTS() else: logger.warning( "Twilio is not set up. You must set TWILIO_ACCOUNT_SID and TWILIO_TOKEN to use the Twilio ICE servers." ) api_accessor = None if config.USE_API: api_accessor = ApiAccessor() event_service = EventService(api_accessor) achievement_service = AchievementService(api_accessor)