File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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
2222the other, but you want to see how this behaves under load.
2323
2424``` go
25+ package main
26+
27+ import (
28+ " github.com/jelmersnoeck/experiment/v3"
29+ )
30+
2531func main () {
2632 exp := experiment.New [string ](
2733 experiment.WithPercentage (50 ),
@@ -50,6 +56,10 @@ about your new implementation.
5056
5157## Usage
5258
59+ ### Import
60+
61+ This package uses go modules. To import it, use ` github.com/jelmersnoeck/experiment/v3 ` as import path.
62+
5363### Control
5464
5565` Control(func(context.Context) (any, error)) ` should be used to implement your
6171
6272``` go
6373func main () {
64- exp := experiment.New (
74+ exp := experiment.New [ string ] (
6575 experiment.WithPercentage (50 ),
6676 )
6777
@@ -236,7 +246,7 @@ Observation values through a provided logger or the standard library logger.
236246
237247``` go
238248func main () {
239- exp := experiment.New (
249+ exp := experiment.New [ string ] (
240250 experiment.WithPercentage (50 ),
241251 ).WithPublisher (experiment.NewLogPublisher [string ](" publisher" , nil ))
242252
Original file line number Diff line number Diff line change 88 "net/http"
99 "time"
1010
11- "github.com/jelmersnoeck/experiment"
11+ "github.com/jelmersnoeck/experiment/v3 "
1212)
1313
1414type handleFunc func (http.ResponseWriter , * http.Request )
@@ -50,6 +50,15 @@ func exampleHandler() handleFunc {
5050 return "" , errors .New ("bar" )
5151 })
5252
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+
5362 exp .Compare (func (control , candidate string ) bool {
5463 fmt .Printf ("Comparing '%s' with '%s'\n " , control , candidate )
5564 return control == candidate
Original file line number Diff line number Diff line change 88 "testing"
99 "time"
1010
11- "github.com/jelmersnoeck/experiment"
11+ "github.com/jelmersnoeck/experiment/v3 "
1212)
1313
1414func 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
22
33go 1.19
Original file line number Diff line number Diff line change 44 "context"
55 "fmt"
66
7- "github.com/jelmersnoeck/experiment"
7+ "github.com/jelmersnoeck/experiment/v3 "
88)
99
1010func ExampleLogPublisher () {
You can’t perform that action at this time.
0 commit comments