-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from kelseyaubrecht/feat/datagrams
Feat/datagrams
- Loading branch information
Showing
9 changed files
with
294 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package wt | ||
|
||
import ( | ||
"log" | ||
"time" | ||
|
||
"go.k6.io/k6/metrics" | ||
) | ||
|
||
func (c *Connection) SendDatagram(p []byte) { | ||
err := c.Session.SendDatagram(p) | ||
defer c.logSendDatagramMetrics(len(p)) | ||
if err != nil { | ||
log.Println("SendDatagram error: " + err.Error()) | ||
} | ||
} | ||
|
||
func (c *Connection) ReceiveDatagram() []byte { | ||
p, err := c.Session.ReceiveDatagram(c.Session.Context()) | ||
if err != nil { | ||
log.Println("ReceiveDatagram error: " + err.Error()) | ||
} | ||
defer c.logRecvDatagramMetrics(len(p)) | ||
return p | ||
} | ||
|
||
func (c *Connection) logSendDatagramMetrics(n int) { | ||
state := c.vu.State() | ||
ctx := c.vu.Context() | ||
if state == nil || ctx == nil { | ||
return | ||
} | ||
|
||
now := time.Now() | ||
|
||
metrics.PushIfNotDone(ctx, state.Samples, metrics.ConnectedSamples{ | ||
Samples: []metrics.Sample{ | ||
{ | ||
Time: now, | ||
TimeSeries: metrics.TimeSeries{Metric: c.metrics.DatagramsSentCount}, | ||
Value: 1, | ||
}, | ||
{ | ||
Time: now, | ||
TimeSeries: metrics.TimeSeries{Metric: c.metrics.DatagramsSentBytes}, | ||
Value: float64(n), | ||
}, | ||
}, | ||
Time: now, | ||
}) | ||
} | ||
|
||
func (c *Connection) logRecvDatagramMetrics(n int) { | ||
state := c.vu.State() | ||
ctx := c.vu.Context() | ||
if state == nil || ctx == nil { | ||
return | ||
} | ||
|
||
now := time.Now() | ||
|
||
metrics.PushIfNotDone(ctx, state.Samples, metrics.ConnectedSamples{ | ||
Samples: []metrics.Sample{ | ||
{ | ||
Time: now, | ||
TimeSeries: metrics.TimeSeries{Metric: c.metrics.DatagramsRecvCount}, | ||
Value: 1, | ||
}, | ||
{ | ||
Time: now, | ||
TimeSeries: metrics.TimeSeries{Metric: c.metrics.DatagramsRecvBytes}, | ||
Value: float64(n), | ||
}, | ||
}, | ||
Time: now, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import wt from "k6/x/webtransport"; | ||
|
||
export default function () { | ||
const url = "https://localhost:443/webtransport"; | ||
let data = [0, 1, 2, 3, 4]; | ||
|
||
wt.connect(url); | ||
|
||
wt.sendDatagram(data); | ||
|
||
const response = wt.receiveDatagram(); | ||
// handle response | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,59 @@ | ||
module github.com/kelseyaubrecht/xk6-webtransport | ||
|
||
go 1.22 | ||
go 1.21 | ||
|
||
require ( | ||
github.com/quic-go/webtransport-go v0.6.0 | ||
go.k6.io/k6 v0.48.0 | ||
github.com/quic-go/webtransport-go v0.8.0 | ||
go.k6.io/k6 v0.50.0 | ||
) | ||
|
||
require ( | ||
github.com/cenkalti/backoff/v4 v4.2.1 // indirect | ||
github.com/dlclark/regexp2 v1.9.0 // indirect | ||
github.com/dop251/goja v0.0.0-20231027120936-b396bb4c349d // indirect | ||
github.com/fatih/color v1.15.0 // indirect | ||
github.com/go-logr/logr v1.2.4 // indirect | ||
github.com/go-logr/logr v1.4.1 // indirect | ||
github.com/go-logr/stdr v1.2.2 // indirect | ||
github.com/go-sourcemap/sourcemap v2.1.4-0.20211119122758-180fcef48034+incompatible // indirect | ||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect | ||
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect | ||
github.com/golang/protobuf v1.5.3 // indirect | ||
github.com/google/pprof v0.0.0-20230821062121-407c9e7a662f // indirect | ||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect | ||
go.opentelemetry.io/otel v1.21.0 // indirect | ||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect | ||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 // indirect | ||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0 // indirect | ||
go.opentelemetry.io/otel/metric v1.21.0 // indirect | ||
go.opentelemetry.io/otel/sdk v1.21.0 // indirect | ||
go.opentelemetry.io/otel/trace v1.21.0 // indirect | ||
go.opentelemetry.io/proto/otlp v1.0.0 // indirect | ||
google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 // indirect | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect | ||
google.golang.org/grpc v1.60.0 // indirect | ||
google.golang.org/protobuf v1.33.0 // indirect | ||
) | ||
|
||
require ( | ||
github.com/dlclark/regexp2 v1.11.0 // indirect | ||
github.com/dop251/goja v0.0.0-20240220182346-e401ed450204 // indirect | ||
github.com/fatih/color v1.16.0 // indirect | ||
github.com/go-sourcemap/sourcemap v2.1.4+incompatible // indirect | ||
github.com/google/pprof v0.0.0-20240507183855-6f11f98ebb1c // indirect | ||
github.com/josharian/intern v1.0.0 // indirect | ||
github.com/mailru/easyjson v0.7.7 // indirect | ||
github.com/mattn/go-colorable v0.1.13 // indirect | ||
github.com/mattn/go-isatty v0.0.19 // indirect | ||
github.com/mattn/go-isatty v0.0.20 // indirect | ||
github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd // indirect | ||
github.com/onsi/ginkgo v1.16.5 // indirect | ||
github.com/onsi/ginkgo/v2 v2.12.0 // indirect | ||
github.com/onsi/ginkgo/v2 v2.17.3 // indirect | ||
github.com/quic-go/qpack v0.4.0 // indirect | ||
github.com/quic-go/qtls-go1-20 v0.4.1 // indirect | ||
github.com/quic-go/quic-go v0.40.0 // indirect | ||
github.com/quic-go/quic-go v0.43.1 // indirect | ||
github.com/serenize/snaker v0.0.0-20201027110005-a7ad2135616e // indirect | ||
github.com/sirupsen/logrus v1.9.3 // indirect | ||
github.com/spf13/afero v1.1.2 // indirect | ||
go.opentelemetry.io/otel v1.19.0 // indirect | ||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 // indirect | ||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 // indirect | ||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 // indirect | ||
go.opentelemetry.io/otel/metric v1.19.0 // indirect | ||
go.opentelemetry.io/otel/sdk v1.19.0 // indirect | ||
go.opentelemetry.io/otel/trace v1.19.0 // indirect | ||
go.opentelemetry.io/proto/otlp v1.0.0 // indirect | ||
go.uber.org/mock v0.3.0 // indirect | ||
golang.org/x/crypto v0.14.0 // indirect | ||
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect | ||
golang.org/x/mod v0.12.0 // indirect | ||
golang.org/x/net v0.17.0 // indirect | ||
golang.org/x/sys v0.13.0 // indirect | ||
golang.org/x/text v0.13.0 // indirect | ||
golang.org/x/time v0.3.0 // indirect | ||
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect | ||
google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 // indirect | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230731193218-e0aa005b6bdf // indirect | ||
google.golang.org/grpc v1.58.3 // indirect | ||
google.golang.org/protobuf v1.31.0 // indirect | ||
gopkg.in/guregu/null.v3 v3.3.0 // indirect | ||
github.com/spf13/afero v1.11.0 // indirect | ||
go.uber.org/mock v0.4.0 // indirect | ||
golang.org/x/crypto v0.23.0 // indirect | ||
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect | ||
golang.org/x/mod v0.17.0 // indirect | ||
golang.org/x/net v0.25.0 // indirect | ||
golang.org/x/sys v0.20.0 // indirect | ||
golang.org/x/text v0.15.0 // indirect | ||
golang.org/x/time v0.5.0 // indirect | ||
golang.org/x/tools v0.21.0 // indirect | ||
gopkg.in/guregu/null.v3 v3.5.0 // indirect | ||
) |
Oops, something went wrong.