Search and commands

↑ ↓ to select · Enter to open · Esc to close

Type to search packages.

rls

v1.51.4
github.com/lfch/grpc/internal/testutils/rls

Documentation

pkg.go.dev ↗

Table of contents

↓ to select · Enter to jump· Shift+Enter for source

8 matches

Top ↑

Package rls contains utilities for RouteLookupService e2e tests.

Types

FakeRouteLookupServer

type FakeRouteLookupServer struct {
	rlsgrpc.UnimplementedRouteLookupServiceServer
	Address string
	// contains filtered or unexported fields
}

FakeRouteLookupServer is a fake implementation of the RouteLookupService.

It is safe for concurrent use.

SetupFakeRLSServer

func SetupFakeRLSServer(t *testing.T, lis net.Listener, opts ...grpc.ServerOption) (*FakeRouteLookupServer, chan struct{})

SetupFakeRLSServer starts and returns a fake RouteLookupService server listening on the given listener or on a random local port. Also returns a channel for tests to get notified whenever the RouteLookup RPC is invoked on the fake server.

This function sets up the fake server to respond with an empty response for the RouteLookup RPCs. Tests can override this by calling the SetResponseCallback() method on the returned fake server.

StartFakeRouteLookupServer

func StartFakeRouteLookupServer(t *testing.T, lis net.Listener, opts ...grpc.ServerOption) (*FakeRouteLookupServer, func())

StartFakeRouteLookupServer starts a fake RLS server listening for requests on lis. If lis is nil, it creates a new listener on a random local port. The returned cancel function should be invoked by the caller upon completion of the test.

FakeRouteLookupServer.RouteLookup

func (s *FakeRouteLookupServer) RouteLookup(ctx context.Context, req *rlspb.RouteLookupRequest) (*rlspb.RouteLookupResponse, error)

RouteLookup implements the RouteLookupService.

FakeRouteLookupServer.SetRequestCallback

func (s *FakeRouteLookupServer) SetRequestCallback(f func(*rlspb.RouteLookupRequest))

SetRequestCallback sets a callback to be invoked on every RLS request. The callback is given the incoming request, and tests can use this to verify that the request matches its expectations.

FakeRouteLookupServer.SetResponseCallback

func (s *FakeRouteLookupServer) SetResponseCallback(f func(context.Context, *rlspb.RouteLookupRequest) *RouteLookupResponse)

SetResponseCallback sets a callback to be invoked on every RLS request. If this callback is set, the response returned by the fake server depends on the value returned by the callback. If this callback is not set, the fake server responds with an empty response.

RouteLookupResponse

type RouteLookupResponse struct {
	Resp *rlspb.RouteLookupResponse
	Err  error
}

RouteLookupResponse wraps an RLS response and the associated error to be sent to a client when the RouteLookup RPC is invoked.

Dependency graph