1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-09-17 02:16:54 +00:00

Moved rate.Limiter into its own package

This commit is contained in:
Kane York 2017-02-02 23:20:10 -08:00
parent 7be7fc5c3a
commit 1da392f5b3
7 changed files with 22 additions and 23 deletions

View file

@ -1,12 +1,11 @@
package server
// This is the scariest code I've written yet for the server.
// If I screwed up the locking, I won't know until it's too late.
import (
"log"
"sync"
"time"
"github.com/FrankerFaceZ/FrankerFaceZ/socketserver/server/rate"
)
type SubscriberList struct {
@ -60,7 +59,7 @@ func SubscribeGlobal(client *ClientInfo) {
GlobalSubscriptionLock.Unlock()
}
func PublishToChannel(channel string, msg ClientMessage, rl RateLimit) (count int) {
func PublishToChannel(channel string, msg ClientMessage, rl rate.Limiter) (count int) {
var found []*ClientInfo
ChatSubscriptionLock.RLock()
@ -82,7 +81,7 @@ func PublishToChannel(channel string, msg ClientMessage, rl RateLimit) (count in
return
}
func PublishToMultiple(channels []string, msg ClientMessage, rl RateLimit) (count int) {
func PublishToMultiple(channels []string, msg ClientMessage, rl rate.Limiter) (count int) {
var found []*ClientInfo
ChatSubscriptionLock.RLock()
@ -107,7 +106,7 @@ func PublishToMultiple(channels []string, msg ClientMessage, rl RateLimit) (coun
return count
}
func PublishToAll(msg ClientMessage, rl RateLimit) (count int) {
func PublishToAll(msg ClientMessage, rl rate.Limiter) (count int) {
var found []*ClientInfo
GlobalSubscriptionLock.RLock()