Skip to content
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

Add method for publishing messages to redis channels #24

Merged
merged 2 commits into from
Dec 20, 2022

Conversation

bdach
Copy link
Contributor

@bdach bdach commented Dec 19, 2022

This is the (modest) start of a series of pulls whose end goal is to develop a full no-polling flow which can be used to deliver notifications about score processing completion to lazer clients, therefore providing a facility to complete ppy/osu#18877. The general expected shape of the full flow can be previewed on this diagram.

It's mostly just one method, that is going to be used further in osu-queue-score-statistics. The rationale of exposing it is roughly the following:

  • Other queue operations are already similarly exposed
  • StackExchange.Redis' ConnectionMultiplexer is intended for reuse, so I see little basis to instantiate local instances in consumer projects
  • There is a bit of glue code (JSON serialisation, observability) that can be offered out-of-the-box if this is placed here.

public void PublishMessage<TMessage>(string channelName, TMessage message)
{
redis.GetDatabase().Publish(channelName, JsonConvert.SerializeObject(message));
DogStatsd.Increment("messages_published", tags: new[] { $"channel:{channelName}", $"type:{typeof(TMessage).FullName}" });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dunno if this is overkill or not. Given that Redis's pubsub is a no-guarantees implementation, it felt like it may be nice to get counts from the publisher directly? I don't see datadog having anything in-house that could add this sort of tracking. Definitely think it's a good idea to have some sort of observability at a few stages of this flow to be able to diagnose failures better, though.

@peppy peppy merged commit 12826fd into ppy:master Dec 20, 2022
@bdach bdach deleted the event-publishing branch December 20, 2022 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants