@@ -22,16 +22,20 @@ type Options[Resource any] struct {
22
22
// By default, 2*MinDuration.
23
23
MaxDuration time.Duration
24
24
// LoadResource loads resource with given key from a database. Returning an error aborts the batch.
25
- // This function is called in the beginning of each new batch. Context passed as a first parameter
26
- // has a timeout calculated using batch MaxDuration. You can use this information to abort loading resource
27
- // if it takes too long.
25
+ // This function is called in the beginning of each new batch.
26
+ //
27
+ // Context passed as a first parameter has a timeout calculated using batch MaxDuration.
28
+ // You can watch context cancellation in order to abort loading resource if it takes too long.
29
+ // Context is also cancelled after batch was ended.
28
30
//
29
31
// By default, returns zero-value Resource.
30
32
LoadResource func (_ context.Context , key string ) (Resource , error )
31
33
// SaveResource saves resource with given key to a database. Returning an error aborts the batch.
32
- // This function is called at the end of each batch. Context passed as a first parameter
33
- // has a timeout calculated using batch MaxDuration. You can use this information to abort saving resource
34
- // if it takes too long (thus aborting the entire batch).
34
+ // This function is called at the end of each batch.
35
+ //
36
+ // Context passed as a first parameter has a timeout calculated using batch MaxDuration.
37
+ // You can watch context cancellation in order to abort saving resource if it takes too long
38
+ // (thus aborting the entire batch). Context is also cancelled after batch was ended.
35
39
//
36
40
// By default, does nothing.
37
41
SaveResource func (_ context.Context , key string , _ Resource ) error
0 commit comments