Skip to content

Commit

Permalink
Merge pull request #24 from bdach/event-publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy authored Dec 20, 2022
2 parents d610e80 + a6056b1 commit 12826fd
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions osu.Server.QueueProcessor/QueueProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,22 @@ public long GetQueueSize() =>

public void ClearQueue() => redis.GetDatabase().KeyDelete(QueueName);

/// <summary>
/// Publishes a message to a Redis channel with the supplied <paramref name="channelName"/>.
/// </summary>
/// <remarks>
/// The message will be serialised using JSON.
/// Successful publications are tracked in Datadog, using the <paramref name="channelName"/> and the <typeparamref name="TMessage"/>'s full type name as a tag.
/// </remarks>
/// <param name="channelName">The name of the Redis channel to publish to.</param>
/// <param name="message">The message to publish to the channel.</param>
/// <typeparam name="TMessage">The type of message to be published.</typeparam>
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}" });
}

/// <summary>
/// Retrieve a database connection.
/// </summary>
Expand Down

0 comments on commit 12826fd

Please sign in to comment.