-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstrategy.go
23 lines (19 loc) · 962 Bytes
/
strategy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package dataloader
import (
"context"
)
// Strategy specifies the interface of loader strategies. A loader strategy specifies the process
// of calling the batch function and handling requests to fetch data.
type Strategy interface {
// Load returns a Thunk for the specified Key.
// Internally load adds the provided key to the keys array and returns a callback function linked
// to the key which blocks when called until the the batch function is called.
Load(context.Context, Key) Thunk
// LoadMany returns a ThunkMany which returns a ResultMap for the keys it was called for.
// When called, callback blocks until the batch function is called.
LoadMany(context.Context, ...Key) ThunkMany
// LoadNoNop doesn't block the caller and doesn't return a value when called.
// LoadNoOp is called after a cache hit and the found result value is returned to the caller
// and thus simply increments the loads call counter.
LoadNoOp(context.Context)
}