package relaytest
import "github.com/uber/tchannel-go/relay/relaytest"
Index ¶
- func HostFunc(fn func(relay.CallFrame, *relay.Conn) (string, error)) tchannel.RelayHost
- type FluentMockCallStats
- func (f *FluentMockCallStats) Failed(reason string) *FluentMockCallStats
- func (f *FluentMockCallStats) Succeeded() *FluentMockCallStats
- type MockCallStats
- func (m *MockCallStats) End()
- func (m *MockCallStats) Failed(reason string)
- func (m *MockCallStats) ReceivedBytes(size uint16)
- func (m *MockCallStats) SentBytes(size uint16)
- func (m *MockCallStats) Succeeded()
- type MockStats
- func NewMockStats() *MockStats
- func (m *MockStats) Add(caller, callee, procedure string) *FluentMockCallStats
- func (m *MockStats) AssertEqual(t testing.TB, expected *MockStats)
- func (m *MockStats) Begin(f relay.CallFrame) *MockCallStats
- func (m *MockStats) Map() map[string]int
- func (m *MockStats) WaitForEnd()
- type StubRelayHost
- func NewStubRelayHost() *StubRelayHost
- func (rh *StubRelayHost) Add(service, hostPort string)
- func (rh *StubRelayHost) SetChannel(ch *tchannel.Channel)
- func (rh *StubRelayHost) SetFrameFn(f func(relay.CallFrame, *relay.Conn))
- func (rh *StubRelayHost) SetRespFrameFn(f func(relay.RespFrame))
- func (rh *StubRelayHost) Start(cf relay.CallFrame, conn *relay.Conn) (tchannel.RelayCall, error)
- func (rh *StubRelayHost) Stats() *MockStats
Functions ¶
func HostFunc ¶
HostFunc wraps a given function to implement tchannel.RelayHost.
Types ¶
type FluentMockCallStats ¶
type FluentMockCallStats struct { *MockCallStats }
FluentMockCallStats wraps the MockCallStats in a fluent API that's convenient for tests.
func (*FluentMockCallStats) Failed ¶
func (f *FluentMockCallStats) Failed(reason string) *FluentMockCallStats
Failed marks the RPC as failed.
func (*FluentMockCallStats) Succeeded ¶
func (f *FluentMockCallStats) Succeeded() *FluentMockCallStats
Succeeded marks the RPC as succeeded.
type MockCallStats ¶
type MockCallStats struct {
// contains filtered or unexported fields
}
MockCallStats is a testing spy for the CallStats interface.
func (*MockCallStats) End ¶
func (m *MockCallStats) End()
End halts timer and metric collection for the RPC.
func (*MockCallStats) Failed ¶
func (m *MockCallStats) Failed(reason string)
Failed marks the RPC as failed for the provided reason.
func (*MockCallStats) ReceivedBytes ¶
func (m *MockCallStats) ReceivedBytes(size uint16)
ReceivedBytes tracks the received bytes.
func (*MockCallStats) SentBytes ¶
func (m *MockCallStats) SentBytes(size uint16)
SentBytes tracks the sent bytes.
func (*MockCallStats) Succeeded ¶
func (m *MockCallStats) Succeeded()
Succeeded marks the RPC as succeeded.
type MockStats ¶
type MockStats struct {
// contains filtered or unexported fields
}
MockStats is a testing spy for the Stats interface.
func NewMockStats ¶
func NewMockStats() *MockStats
NewMockStats constructs a MockStats.
func (*MockStats) Add ¶
func (m *MockStats) Add(caller, callee, procedure string) *FluentMockCallStats
Add explicitly adds a new call along an edge of the call graph.
func (*MockStats) AssertEqual ¶
AssertEqual asserts that two MockStats describe the same call graph.
func (*MockStats) Begin ¶
func (m *MockStats) Begin(f relay.CallFrame) *MockCallStats
Begin starts collecting metrics for an RPC.
func (*MockStats) Map ¶
Map returns all stats as a map of key to int. It waits for any ongoing calls to end first to avoid races.
func (*MockStats) WaitForEnd ¶
func (m *MockStats) WaitForEnd()
WaitForEnd waits for all calls to End.
type StubRelayHost ¶
type StubRelayHost struct {
// contains filtered or unexported fields
}
StubRelayHost is a stub RelayHost for tests that backs peer selection to an underlying channel using isolated subchannels and the default peer selection.
func NewStubRelayHost ¶
func NewStubRelayHost() *StubRelayHost
NewStubRelayHost creates a new stub RelayHost for tests.
func (*StubRelayHost) Add ¶
func (rh *StubRelayHost) Add(service, hostPort string)
Add adds a service instance with the specified host:port.
func (*StubRelayHost) SetChannel ¶
func (rh *StubRelayHost) SetChannel(ch *tchannel.Channel)
SetChannel is called by the channel after creation so we can get a reference to the channels' peers.
func (*StubRelayHost) SetFrameFn ¶
func (rh *StubRelayHost) SetFrameFn(f func(relay.CallFrame, *relay.Conn))
SetFrameFn sets a function to run on every frame.
func (*StubRelayHost) SetRespFrameFn ¶
func (rh *StubRelayHost) SetRespFrameFn(f func(relay.RespFrame))
SetRespFrameFn sets a function to run on every frame.
func (*StubRelayHost) Start ¶
Start starts a new RelayCall for the given call on a specific connection.
func (*StubRelayHost) Stats ¶
func (rh *StubRelayHost) Stats() *MockStats
Stats returns the *MockStats tracked for this channel.
Source Files ¶
func_host.go mock_stats.go stub_host.go
- Version
- v1.34.6 (latest)
- Published
- Jan 8, 2025
- Platform
- windows/amd64
- Imports
- 9 packages
- Last checked
- 2 hours ago –
Tools for package owners.