Skip to content

Multiple windows per one synchronizer #3

@reddec

Description

@reddec

Good day!

Is it possible to use one synchronizer with multiple windows and multiple limiters (ie: multiple clients)?

Pseudo code

synchronizer := NewNonBlockingSynchronizer()
for _, key := range keys {
  limiter, stop := slidingwindow.NewLimiter(interval, rate, func() (slidingwindow.Window, slidingwindow.StopFunc) {
    return slidingwindow.NewSyncWindow(key, synchronizer)
  })
}

SyncWindow code always starts Synchronizer

w.syncer.Start()

however, in NonBlockingSynchronizer there are no checks for a double launch

go s.syncLoop()

So I suspect that the number of goroutines will be roughly equal to the number of limiters, that sounds quite overkill.
Is it a bug, feature, or I missed something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions