Skip to content

Commit

Permalink
Add firebase subscriber to topics from cache upon initialization; str…
Browse files Browse the repository at this point in the history
…icter rate limits
  • Loading branch information
Philipp Heckel committed Nov 4, 2021
1 parent eef85c0 commit 5948f39
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ const (
)

// Defines all the limits
// - request limit: max number of PUT/GET/.. requests (here: 50 requests bucket, replenished at a rate of 1 per second)
// - request limit: max number of PUT/GET/.. requests (here: 50 requests bucket, replenished at a rate of one per 10 seconds)
// - global topic limit: max number of topics overall
// - subscription limit: max number of subscriptions (active HTTP connections) per per-visitor/IP
var (
defaultGlobalTopicLimit = 5000
defaultVisitorRequestLimit = rate.Every(time.Second)
defaultVisitorRequestLimit = rate.Every(10 * time.Second)
defaultVisitorRequestLimitBurst = 50
defaultVisitorSubscriptionLimit = 30
)
Expand Down
7 changes: 6 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (e errHTTP) Error() string {
}

const (
messageLimit = 1024
messageLimit = 512
)

var (
Expand Down Expand Up @@ -86,6 +86,11 @@ func New(conf *config.Config) (*Server, error) {
if err != nil {
return nil, err
}
for _, t := range topics {
if firebaseSubscriber != nil {
t.Subscribe(firebaseSubscriber)
}
}
return &Server{
config: conf,
cache: cache,
Expand Down

0 comments on commit 5948f39

Please sign in to comment.