Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pkg/moqt/session/datastream_timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ func (b *blockedSendStream) SetWriteDeadline(t time.Time) error {
// a deadline that was not armed is a failure, not a hang.
var errNeverArmed = errors.New("blockedSendStream: no write deadline was armed")

func (b *blockedSendStream) Write(p []byte) (int, error) {
func (b *blockedSendStream) Write([]byte) (int, error) {
b.mu.Lock()
deadline := b.deadline
b.mu.Unlock()
Expand Down Expand Up @@ -751,6 +751,7 @@ func TestObjectDeliveryTimeoutLiftsTheDeadline(t *testing.T) {
// set on it and writes at once.
type deadlineRecordingSendStream struct {
*fakeSendStream

deadlines []time.Time
}

Expand Down Expand Up @@ -781,7 +782,10 @@ func BenchmarkWriteObjectWithDeadline(b *testing.B) {
func TestObjectDeliveryTimeoutNoDeadlineWithoutTimeout(t *testing.T) {
dst := newFakeSendStream()
out := session.NewOutgoingSubgroupStream(dst)
if err := out.WriteObjectReceivedAt(time.Now().Add(-time.Hour), &message.SubgroupObject{Payload: []byte("x")}); err != nil {
if err := out.WriteObjectReceivedAt(
time.Now().Add(-time.Hour),
&message.SubgroupObject{Payload: []byte("x")},
); err != nil {
t.Fatalf("an hour-old object with no timeout should still be written: %v", err)
}
}
4 changes: 3 additions & 1 deletion pkg/moqt/session/urgency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ func TestUrgency(t *testing.T) {
subscriber uint8
want int8
}{{0, 1}, {1, 1}, {64, 2}, {128, 4}, {200, 5}, {255, 7}} {
if got := session.Urgency(session.StreamPriority{Subscriber: tc.subscriber, Publisher: 255, GroupKey: 1 << 60}); got != tc.want {
if got := session.Urgency(
session.StreamPriority{Subscriber: tc.subscriber, Publisher: 255, GroupKey: 1 << 60},
); got != tc.want {
t.Errorf("Urgency(subscriber %d) = %d, want %d", tc.subscriber, got, tc.want)
}
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/moqt/session/wtconn/wtconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,14 @@ type prioritizer interface {
// the transport will do.
func wrapSendStream(s *webtransport.SendStream) session.SendStream {
if p, ok := any(s).(prioritizer); ok {
return &prioritizedSendStream{sendStream: sendStream{s: s}, p: p}
return &prioritizedSendStream{s: s, p: p}
}
return &sendStream{s: s}
}

type prioritizedSendStream struct {
sendStream

p prioritizer
}

Expand Down
10 changes: 9 additions & 1 deletion pkg/relay/handler_fanout.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,15 @@ func (h *sessionHandler) runFanout(ctx context.Context, stream *session.Incoming
}

// Counted after the dedup claim, so redundant copies don't count.
h.metrics.ObjectReceived(ref, ReceivedObject{Name: entry.FullName, Subgroup: hdr.SubgroupID, HeaderAt: headerAt, Properties: obj.Properties})
h.metrics.ObjectReceived(
ref,
ReceivedObject{
Name: entry.FullName,
Subgroup: hdr.SubgroupID,
HeaderAt: headerAt,
Properties: obj.Properties,
},
)

cached := &cache.CachedObject{
GroupID: hdr.GroupID,
Expand Down
9 changes: 7 additions & 2 deletions pkg/relay/metrics_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package relay_test

import (
"bytes"
"errors"
"maps"
"sync"
"sync/atomic"
"testing"
"time"

"bytes"
"github.com/floatdrop/moq-go/pkg/moqt/message"
"github.com/floatdrop/moq-go/pkg/moqt/session"
"github.com/floatdrop/moq-go/pkg/relay"
Expand Down Expand Up @@ -67,7 +67,12 @@ func (m *recordingMetrics) SubscriptionClosed(relay.TrackRef) { m.subsClosed.Add

func (m *recordingMetrics) ObjectReceived(_ relay.TrackRef, o relay.ReceivedObject) {
m.mu.Lock()
m.lastReceived = relay.ReceivedObject{Name: o.Name, Subgroup: o.Subgroup, HeaderAt: o.HeaderAt, Properties: bytes.Clone(o.Properties)}
m.lastReceived = relay.ReceivedObject{
Name: o.Name,
Subgroup: o.Subgroup,
HeaderAt: o.HeaderAt,
Properties: bytes.Clone(o.Properties),
}
m.mu.Unlock()
m.received.Add(1)
}
Expand Down
Loading