Skip to content

Commit 71de3f7

Browse files
authored
Release v3 (#31)
* Release v3 * Update readme
1 parent fcb88e5 commit 71de3f7

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ current package you're using. Tests help you transition from one package to
2222
the 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+
2531
func 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
@@ -61,7 +71,7 @@ panic.
6171

6272
```go
6373
func 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
238248
func main() {
239-
exp := experiment.New(
249+
exp := experiment.New[string](
240250
experiment.WithPercentage(50),
241251
).WithPublisher(experiment.NewLogPublisher[string]("publisher", nil))
242252

_examples/http_handler.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"net/http"
99
"time"
1010

11-
"github.com/jelmersnoeck/experiment"
11+
"github.com/jelmersnoeck/experiment/v3"
1212
)
1313

1414
type 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

experiment_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"testing"
99
"time"
1010

11-
"github.com/jelmersnoeck/experiment"
11+
"github.com/jelmersnoeck/experiment/v3"
1212
)
1313

1414
func TestRun(t *testing.T) {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
module github.com/jelmersnoeck/experiment
1+
module github.com/jelmersnoeck/experiment/v3
22

33
go 1.19

publisher_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"fmt"
66

7-
"github.com/jelmersnoeck/experiment"
7+
"github.com/jelmersnoeck/experiment/v3"
88
)
99

1010
func ExampleLogPublisher() {

0 commit comments

Comments
 (0)