grpc: google.golang.org/grpc/internal/stubserver Index | Files

package stubserver

import "google.golang.org/grpc/internal/stubserver"

Package stubserver is a stubbable implementation of google.golang.org/grpc/test/grpc_testing for testing purposes.

Index

Package Files

stubserver.go

type StubServer Uses

type StubServer struct {
    // Guarantees we satisfy this interface; panics if unimplemented methods are called.
    testpb.TestServiceServer

    // Customizable implementations of server handlers.
    EmptyCallF      func(ctx context.Context, in *testpb.Empty) (*testpb.Empty, error)
    UnaryCallF      func(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error)
    FullDuplexCallF func(stream testpb.TestService_FullDuplexCallServer) error

    // A client connected to this service the test may use.  Created in Start().
    Client testpb.TestServiceClient
    CC     *grpc.ClientConn
    S      *grpc.Server

    // Parameters for Listen and Dial. Defaults will be used if these are empty
    // before Start.
    Network string
    Address string
    Target  string

    // Set automatically if Target == ""
    R   *manual.Resolver
    // contains filtered or unexported fields
}

StubServer is a server that is easy to customize within individual test cases.

func (*StubServer) EmptyCall Uses

func (ss *StubServer) EmptyCall(ctx context.Context, in *testpb.Empty) (*testpb.Empty, error)

EmptyCall is the handler for testpb.EmptyCall

func (*StubServer) FullDuplexCall Uses

func (ss *StubServer) FullDuplexCall(stream testpb.TestService_FullDuplexCallServer) error

FullDuplexCall is the handler for testpb.FullDuplexCall

func (*StubServer) NewServiceConfig Uses

func (ss *StubServer) NewServiceConfig(sc string)

NewServiceConfig applies sc to ss.Client using the resolver (if present).

func (*StubServer) Start Uses

func (ss *StubServer) Start(sopts []grpc.ServerOption, dopts ...grpc.DialOption) error

Start starts the server and creates a client connected to it.

func (*StubServer) Stop Uses

func (ss *StubServer) Stop()

Stop stops ss and cleans up all resources it consumed.

func (*StubServer) UnaryCall Uses

func (ss *StubServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error)

UnaryCall is the handler for testpb.UnaryCall

Package stubserver imports 10 packages (graph). Updated 2020-12-05. Refresh now. Tools for package owners.