MCPcopy Create free account
hub / github.com/cloud-native-go/examples / callsCountFunction

Function callsCountFunction

ch04/throttle_test.go:28–33  ·  view source on GitHub ↗

callsCountFunction returns a function that increments the int that callCounter points to whenever it is run.

(callCounter *int)

Source from the content-addressed store, hash-verified

26// callsCountFunction returns a function that increments the int that
27// callCounter points to whenever it is run.
28func callsCountFunction(callCounter *int) Effector {
29 return func(ctx context.Context) (string, error) {
30 *callCounter++
31 return fmt.Sprintf("call %d", *callCounter), nil
32 }
33}
34
35// TestThrottleMax1 tests whether a max of 1 call per duration is respected.
36func TestThrottleMax1(t *testing.T) {

Callers 5

TestThrottleMax1Function · 0.85
TestThrottleMax10Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected