Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/RussellLuo/slidingwindow
/ functions
Functions
67 in github.com/RussellLuo/slidingwindow
⨍
Functions
67
◇
Types & classes
20
↓ 16 callers
Method
Add
Add adds delta to the count of the window represented by start, and returns the new count.
synchronizer.go:12
↓ 8 callers
Function
triggerSync
(t time.Time)
slidingwindow_test.go:220
↓ 3 callers
Method
Allow
Allow is shorthand for AllowN(time.Now(), 1).
slidingwindow.go:89
↓ 3 callers
Method
AllowN
AllowN reports whether n events may happen at time now.
slidingwindow.go:94
↓ 3 callers
Method
Count
Count returns the accumulated count.
slidingwindow.go:14
↓ 3 callers
Method
Get
Get returns the count of the window represented by start.
synchronizer.go:15
↓ 3 callers
Function
NewLimiter
NewLimiter creates a new limiter, and returns a function to stop the possible sync behaviour within the current window.
slidingwindow.go:46
↓ 3 callers
Function
NewLocalWindow
()
window.go:18
↓ 3 callers
Method
Reset
Reset sets the state of the window with the given settings.
slidingwindow.go:20
↓ 3 callers
Method
Sync
Sync sends a synchronization request.
window.go:71
↓ 2 callers
Method
AddCount
AddCount increments the accumulated count by n.
slidingwindow.go:17
↓ 2 callers
Method
Begin
(now time.Time)
synchronizer.go:41
↓ 2 callers
Method
End
()
synchronizer.go:46
↓ 2 callers
Method
IsTimeUp
IsTimeUp returns whether it's time to sync data to the central datastore.
synchronizer.go:33
↓ 2 callers
Method
Limit
Limit returns the maximum events permitted to happen during one window size.
slidingwindow.go:75
↓ 2 callers
Method
Start
Start returns the start boundary.
slidingwindow.go:11
↓ 2 callers
Method
fullKey
(key string, start int64)
slidingwindow_test.go:104
↓ 2 callers
Method
fullKey
(key string, start int64)
example_syncwindow_test.go:23
↓ 2 callers
Method
fullKey
(key string, start int64)
testutil/main.go:47
↓ 2 callers
Function
newSyncHelper
(store Datastore, syncInterval time.Duration)
synchronizer.go:28
↓ 2 callers
Function
testSyncWindow
(t *testing.T, blockingSync bool, cases []caseArg)
slidingwindow_test.go:125
↓ 1 callers
Method
InProgress
()
synchronizer.go:37
↓ 1 callers
Function
NewBlockingSynchronizer
(store Datastore, syncInterval time.Duration)
synchronizer.go:80
↓ 1 callers
Function
NewNonblockingSynchronizer
(store Datastore, syncInterval time.Duration)
synchronizer.go:120
↓ 1 callers
Function
NewRedisDatastore
(client redis.Cmdable, ttl time.Duration)
example_syncwindow_test.go:19
↓ 1 callers
Function
NewRedisDatastore
(client redis.Cmdable, ttl time.Duration)
testutil/main.go:43
↓ 1 callers
Function
NewSyncWindow
NewSyncWindow creates an instance of SyncWindow with the given synchronizer.
window.go:88
↓ 1 callers
Method
SetLimit
SetLimit sets a new Limit for the limiter.
slidingwindow.go:82
↓ 1 callers
Method
Start
Start starts the synchronization goroutine, if any.
window.go:65
↓ 1 callers
Method
Sync
Sync tries to exchange data between the window and the central datastore at time now, to keep the window's count up-to-date.
slidingwindow.go:24
↓ 1 callers
Method
advance
advance updates the current/previous windows resulting from the passage of time.
slidingwindow.go:116
↓ 1 callers
Function
newLimiters
()
testutil/main.go:117
↓ 1 callers
Function
newMemDatastore
()
slidingwindow_test.go:98
↓ 1 callers
Function
parseFlags
()
testutil/main.go:81
↓ 1 callers
Method
syncLoop
syncLoop is a worker that receives a sync request and generates the corresponding sync response.
synchronizer.go:141
Method
Add
(key string, start, delta int64)
slidingwindow_test.go:108
Method
Add
(key string, start, value int64)
example_syncwindow_test.go:27
Method
Add
(key string, start, value int64)
testutil/main.go:51
Method
AddCount
(n int64)
window.go:30
Method
AddCount
(n int64)
window.go:98
Method
Count
()
window.go:26
Function
Example_localWindow
()
example_localwindow_test.go:10
Function
Example_syncWindow
()
example_syncwindow_test.go:51
Method
Get
(key string, start int64)
slidingwindow_test.go:117
Method
Get
(key string, start int64)
example_syncwindow_test.go:38
Method
Get
(key string, start int64)
testutil/main.go:62
Method
Reset
(s time.Time, c int64)
window.go:34
Method
Reset
(s time.Time, c int64)
window.go:103
Method
Size
Size returns the time duration of one window size. Note that the size is defined to be read-only, if you need to change the size, create a new limiter
slidingwindow.go:70
Method
Start
()
synchronizer.go:86
Method
Start
()
synchronizer.go:130
Method
Start
()
window.go:22
Method
Stop
()
synchronizer.go:88
Method
Stop
()
synchronizer.go:134
Method
Stop
Stop stops the synchronization goroutine, if any, and waits for it to exit.
window.go:68
Method
Sync
(req SyncRequest)
synchronizer.go:50
Method
Sync
Sync sends the window's count to the central datastore, and then update the window's count according to the response from the datastore.
synchronizer.go:92
Method
Sync
Sync tries to send the window's count to the central datastore, or to update the window's count according to the response from the latest synchronizat
synchronizer.go:168
Method
Sync
(now time.Time)
window.go:39
Method
Sync
(now time.Time)
window.go:136
Function
TestLimiter_Blocking_SyncWindow_AllowN
(t *testing.T)
slidingwindow_test.go:226
Function
TestLimiter_LocalWindow_AllowN
(t *testing.T)
slidingwindow_test.go:58
Function
TestLimiter_LocalWindow_SetLimit
(t *testing.T)
slidingwindow_test.go:40
Function
TestLimiter_Nonblocking_SyncWindow_AllowN
(t *testing.T)
slidingwindow_test.go:250
Method
handleSyncResponse
(resp SyncResponse)
window.go:123
Function
main
()
testutil/main.go:139
Method
makeSyncRequest
()
window.go:114