-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue/#771 send broadcast info to rabbitmq #779
Issue/#771 send broadcast info to rabbitmq #779
Conversation
Codecov Report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand much about the structure of the Python server.
So my first question is: Why do you need a "BroadcastService" and does it really do what the name implies?
It looks like the broadcast service is not only responsible for broadcasting but also responsible for fetching the dirty games and also clearing them. For me this looks like a violation of separation of concerns.
If the broadcast service follows it's name it should be responsible for broadcasting messages and the services calling it are responsible for delivering the data. If that's not the case, maybe a different name would be better.
In any scenario the gameService (?) should be responsible for clearing it's own dirtylist.
Whether it pushes the list before cleaning it to the broadcast service or whether it offers a "transactional" method for querying and cleaning the dirty games list to be called by the broadcast service doesn't matter.
Mostly this is a refactor of the broadcast loop that used to be part of
I could do that. That's probably nicer than accessing the member variables directly. There's also this bit of code which IMO doesn't belong there either if game.state == GameState.ENDED:
self.game_service.remove_game(game) but I'd rather not mess with refactoring that ATM since it's out of the scope of this PR and getting it wrong could cause all sorts of horrible stuff like ghost games. |
c08b608
to
2cd7835
Compare
2cd7835
to
480d2a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is way over my head in most respects but certainly nothing glaringly wrong from what I can see.
) | ||
self._logger.debug("Broadcast service initialized") | ||
|
||
async def report_dirties(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As someone new to the code base I'd love a brief docstring here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about that?
# The reference to the ServerInstance needs to be established later | ||
service = BroadcastService( | ||
None, | ||
message_queue_service, | ||
game_service, | ||
player_service, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# The reference to the ServerInstance needs to be established later | |
service = BroadcastService( | |
None, | |
message_queue_service, | |
game_service, | |
player_service, | |
) | |
service = BroadcastService( | |
None, # Reference to the Server instance needs to be established later | |
message_queue_service, | |
game_service, | |
player_service, | |
) |
480d2a3
to
eb12ec7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
5e4fdd0
to
b01e871
Compare
Can be used to make intervals changable without restart
This aviods the "unhandled message" error
b01e871
to
ada7ee6
Compare
ada7ee6
to
65207fb
Compare
I refactored the broadcasting logic to its own service which now also posts the broadcast messages to rabbitmq. I stuck with posting them to the same exchange as the
gameResults
for now, but I'd be interested to hear other peoples opinions on whether that makes sense or it should get its own exchange. The 3 part routing key is a little weird since there will never be any success states other than "success" and the CRUD operation will always be "update" and there is no real clear way to specify that the message is a broadcast.I also decided to aggregate all of the game info into a single message just like it is sent during login. Maybe we should take the opportunity to differentiate between
"game_info"
messages that represent a single game and"game_info"
messages that have a"games"
sub-list. Maybe call it"game_list_info"
, or just get rid of the single game version entirely. I think getting rid of the single game version makes a lot of sense as it would maintain consistency with how the other broadcasted info messages look.Closes #771