Skip to content

Commit

Permalink
Release v3 (#31)
Browse files Browse the repository at this point in the history
* Release v3

* Update readme
  • Loading branch information
jelmersnoeck authored May 8, 2023
1 parent fcb88e5 commit 71de3f7
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ current package you're using. Tests help you transition from one package to
the other, but you want to see how this behaves under load.

```go
package main

import (
"github.com/jelmersnoeck/experiment/v3"
)

func main() {
exp := experiment.New[string](
experiment.WithPercentage(50),
Expand Down Expand Up @@ -50,6 +56,10 @@ about your new implementation.

## Usage

### Import

This package uses go modules. To import it, use `github.com/jelmersnoeck/experiment/v3` as import path.

### Control

`Control(func(context.Context) (any, error))` should be used to implement your
Expand All @@ -61,7 +71,7 @@ panic.

```go
func main() {
exp := experiment.New(
exp := experiment.New[string](
experiment.WithPercentage(50),
)

Expand Down Expand Up @@ -236,7 +246,7 @@ Observation values through a provided logger or the standard library logger.

```go
func main() {
exp := experiment.New(
exp := experiment.New[string](
experiment.WithPercentage(50),
).WithPublisher(experiment.NewLogPublisher[string]("publisher", nil))

Expand Down
11 changes: 10 additions & 1 deletion _examples/http_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"net/http"
"time"

"github.com/jelmersnoeck/experiment"
"github.com/jelmersnoeck/experiment/v3"
)

type handleFunc func(http.ResponseWriter, *http.Request)
Expand Down Expand Up @@ -50,6 +50,15 @@ func exampleHandler() handleFunc {
return "", errors.New("bar")
})

exp.Candidate("timeout", func(ctx context.Context) (string, error) {
select {
case <-time.Tick(time.Second):
return "Waited a full second!", nil
case <-ctx.Done():
return "Timeout hit", ctx.Err()
}
})

exp.Compare(func(control, candidate string) bool {
fmt.Printf("Comparing '%s' with '%s'\n", control, candidate)
return control == candidate
Expand Down
2 changes: 1 addition & 1 deletion experiment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"
"time"

"github.com/jelmersnoeck/experiment"
"github.com/jelmersnoeck/experiment/v3"
)

func TestRun(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/jelmersnoeck/experiment
module github.com/jelmersnoeck/experiment/v3

go 1.19
2 changes: 1 addition & 1 deletion publisher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

"github.com/jelmersnoeck/experiment"
"github.com/jelmersnoeck/experiment/v3"
)

func ExampleLogPublisher() {
Expand Down

0 comments on commit 71de3f7

Please sign in to comment.