mirror of
https://github.com/hanzozt/zt.git
synced 2026-10-30 15:04:55 +00:00
Global rebrand of all OpenZiti references to Hanzo ZT: - Go module paths: github.com/openziti/* → github.com/hanzozt/* - Docker images: openziti/* → hanzozt/* - Java packages: org.openziti.* → org.hanzozt.* - Brand: OpenZiti → Hanzo ZT - URLs: openziti.io → hanzozt.dev
57 lines
1.6 KiB
Go
57 lines
1.6 KiB
Go
package xgress_test
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/hanzozt/metrics"
|
|
"github.com/hanzozt/sdk-golang/xgress"
|
|
)
|
|
|
|
type mockFaulter struct{}
|
|
|
|
func (m mockFaulter) ReportForwardingFault(circuitId string, ctrlId string) {
|
|
}
|
|
|
|
type noopMetrics struct{}
|
|
|
|
func (n noopMetrics) MarkAckReceived() {}
|
|
func (n noopMetrics) MarkPayloadDropped() {}
|
|
func (n noopMetrics) MarkDuplicateAck() {}
|
|
func (n noopMetrics) MarkDuplicatePayload() {}
|
|
func (n noopMetrics) BufferBlockedByLocalWindow() {}
|
|
func (n noopMetrics) BufferUnblockedByLocalWindow() {}
|
|
func (n noopMetrics) BufferBlockedByRemoteWindow() {}
|
|
func (n noopMetrics) BufferUnblockedByRemoteWindow() {}
|
|
func (n noopMetrics) PayloadWritten(time.Duration) {}
|
|
func (n noopMetrics) BufferUnblocked(time.Duration) {}
|
|
func (n noopMetrics) SendPayloadBuffered(int64) {}
|
|
func (n noopMetrics) SendPayloadDelivered(int64) {}
|
|
|
|
type MockEnv struct {
|
|
retransmitter *xgress.Retransmitter
|
|
payloadIngester *xgress.PayloadIngester
|
|
metrics xgress.Metrics
|
|
}
|
|
|
|
func NewMockEnv() *MockEnv {
|
|
closeNotify := make(chan struct{})
|
|
metricsRegistry := metrics.NewRegistry("test", nil)
|
|
return &MockEnv{
|
|
retransmitter: xgress.NewRetransmitter(mockFaulter{}, metricsRegistry, closeNotify),
|
|
payloadIngester: xgress.NewPayloadIngester(closeNotify),
|
|
metrics: noopMetrics{},
|
|
}
|
|
}
|
|
|
|
func (self *MockEnv) GetRetransmitter() *xgress.Retransmitter {
|
|
return self.retransmitter
|
|
}
|
|
|
|
func (self *MockEnv) GetPayloadIngester() *xgress.PayloadIngester {
|
|
return self.payloadIngester
|
|
}
|
|
|
|
func (self *MockEnv) GetMetrics() xgress.Metrics {
|
|
return self.metrics
|
|
}
|