File tree Expand file tree Collapse file tree 5 files changed +25
-6
lines changed Expand file tree Collapse file tree 5 files changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,12 @@ current package you're using. Tests help you transition from one package to
22
22
the other, but you want to see how this behaves under load.
23
23
24
24
``` go
25
+ package main
26
+
27
+ import (
28
+ " github.com/jelmersnoeck/experiment/v3"
29
+ )
30
+
25
31
func main () {
26
32
exp := experiment.New [string ](
27
33
experiment.WithPercentage (50 ),
@@ -50,6 +56,10 @@ about your new implementation.
50
56
51
57
## Usage
52
58
59
+ ### Import
60
+
61
+ This package uses go modules. To import it, use ` github.com/jelmersnoeck/experiment/v3 ` as import path.
62
+
53
63
### Control
54
64
55
65
` Control(func(context.Context) (any, error)) ` should be used to implement your
61
71
62
72
``` go
63
73
func main () {
64
- exp := experiment.New (
74
+ exp := experiment.New [ string ] (
65
75
experiment.WithPercentage (50 ),
66
76
)
67
77
@@ -236,7 +246,7 @@ Observation values through a provided logger or the standard library logger.
236
246
237
247
``` go
238
248
func main () {
239
- exp := experiment.New (
249
+ exp := experiment.New [ string ] (
240
250
experiment.WithPercentage (50 ),
241
251
).WithPublisher (experiment.NewLogPublisher [string ](" publisher" , nil ))
242
252
Original file line number Diff line number Diff line change 8
8
"net/http"
9
9
"time"
10
10
11
- "github.com/jelmersnoeck/experiment"
11
+ "github.com/jelmersnoeck/experiment/v3 "
12
12
)
13
13
14
14
type handleFunc func (http.ResponseWriter , * http.Request )
@@ -50,6 +50,15 @@ func exampleHandler() handleFunc {
50
50
return "" , errors .New ("bar" )
51
51
})
52
52
53
+ exp .Candidate ("timeout" , func (ctx context.Context ) (string , error ) {
54
+ select {
55
+ case <- time .Tick (time .Second ):
56
+ return "Waited a full second!" , nil
57
+ case <- ctx .Done ():
58
+ return "Timeout hit" , ctx .Err ()
59
+ }
60
+ })
61
+
53
62
exp .Compare (func (control , candidate string ) bool {
54
63
fmt .Printf ("Comparing '%s' with '%s'\n " , control , candidate )
55
64
return control == candidate
Original file line number Diff line number Diff line change 8
8
"testing"
9
9
"time"
10
10
11
- "github.com/jelmersnoeck/experiment"
11
+ "github.com/jelmersnoeck/experiment/v3 "
12
12
)
13
13
14
14
func TestRun (t * testing.T ) {
Original file line number Diff line number Diff line change 1
- module github.com/jelmersnoeck/experiment
1
+ module github.com/jelmersnoeck/experiment/v3
2
2
3
3
go 1.19
Original file line number Diff line number Diff line change 4
4
"context"
5
5
"fmt"
6
6
7
- "github.com/jelmersnoeck/experiment"
7
+ "github.com/jelmersnoeck/experiment/v3 "
8
8
)
9
9
10
10
func ExampleLogPublisher () {
You can’t perform that action at this time.
0 commit comments