Documentation ¶
Overview ¶
Package rpc provides internal gRPC utilities.
Index ¶
- Constants
- func NewPipeClientConn(ctx context.Context, r io.Reader, w io.Writer, extraOpts ...grpc.DialOption) (*grpc.ClientConn, error)
- func RunServer(r io.Reader, w io.Writer, svcs []*testing.Service, ...) error
- func RunTCPServer(port int, handshakeReq *protocol.HandshakeRequest, stdin io.Reader, ...) error
- type ExecClient
- type GenericClient
- type PipeListener
- type SSHClient
Constants ¶
const MaxMessageSize = 1024 * 1024 * 8
MaxMessageSize is used to tell Tast's GRPC servers and clients the maximum size of messages.
Variables ¶
This section is empty.
Functions ¶
func NewPipeClientConn ¶
func NewPipeClientConn(ctx context.Context, r io.Reader, w io.Writer, extraOpts ...grpc.DialOption) (*grpc.ClientConn, error)
NewPipeClientConn constructs ClientConn based on r and w.
The returned ClientConn is suitable for talking with a gRPC server over a bidirectional pipe.
func RunServer ¶
func RunServer(r io.Reader, w io.Writer, svcs []*testing.Service, register func(srv *grpc.Server, req *protocol.HandshakeRequest) error) error
RunServer runs a gRPC server on r/w channels. register is called back to register core services. svcs is a list of user-defined gRPC services to be registered if the client requests them in HandshakeRequest. RunServer blocks until the client connection is closed or it encounters an error.
func RunTCPServer ¶
func RunTCPServer(port int, handshakeReq *protocol.HandshakeRequest, stdin io.Reader, stdout, stderr io.Writer, svcs []*testing.Service, register func(srv *grpc.Server, req *protocol.HandshakeRequest) error) error
RunTCPServer runs a gRPC server listening on the specified port thought TCP Port contains the TCP port number where gRPC server listens to HandshakeRequest contains parameters needed to initialize a gRPC server. stdin is the linux standard input. stdout is the linux standard output. stderr is the linux standard error. svcs is the candidate list of user-defined gRPC services and they will be registered if GuaranteeCompatibility is set.
Types ¶
type ExecClient ¶
type ExecClient struct {
// contains filtered or unexported fields
}
ExecClient is a Tast gRPC client over a locally executed subprocess.
func DialExec ¶
func DialExec(ctx context.Context, path string, newSession bool, req *protocol.HandshakeRequest) (*ExecClient, error)
DialExec establishes a gRPC connection to an executable on host. If newSession is true, a new session is created for the subprocess and its descendants so that all of them are killed on closing Client.
func (*ExecClient) Conn ¶
func (c *ExecClient) Conn() *grpc.ClientConn
Conn returns a gRPC connection.
type GenericClient ¶
type GenericClient struct {
// contains filtered or unexported fields
}
GenericClient is a Tast gRPC client.
func NewClient ¶
func NewClient(ctx context.Context, r io.Reader, w io.Writer, req *protocol.HandshakeRequest, opts ...grpc.DialOption) (_ *GenericClient, retErr error)
NewClient establishes a gRPC connection to a test bundle executable using r and w. Callers are responsible for closing the underlying connection of r/w after the client is closed.
func (*GenericClient) Conn ¶
func (c *GenericClient) Conn() *grpc.ClientConn
Conn returns a gRPC connection.
type PipeListener ¶
type PipeListener struct {
// contains filtered or unexported fields
}
PipeListener is a pseudo net.Listener implementation based on io.Reader and io.Writer. PipeListener's Accept returns exactly one net.Conn that is based on the given io.Reader and io.Writer. When the connection is closed, Accept returns io.EOF.
PipeListener is suitable for running a gRPC server over a bidirectional pipe.
func NewPipeListener ¶
func NewPipeListener(r io.Reader, w io.Writer) *PipeListener
NewPipeListener constructs a new PipeListener based on r and w.
func (*PipeListener) Accept ¶
func (l *PipeListener) Accept() (net.Conn, error)
Accept returns a connection. See the comment of PipeListener for its behavior.
func (*PipeListener) Addr ¶
func (l *PipeListener) Addr() net.Addr
Addr returns a fake IPv4 address.
type SSHClient ¶
type SSHClient struct {
// contains filtered or unexported fields
}
SSHClient is a Tast gRPC client over an SSH connection.
func DialSSH ¶
func DialSSH(ctx context.Context, conn *ssh.Conn, path string, req *protocol.HandshakeRequest, proxy bool) (*SSHClient, error)
DialSSH establishes a gRPC connection to an executable on a remote machine. proxy if true indicates that HTTP proxy environment variables should be forwarded.
The context passed in must remain valid for as long as the gRPC connection. I.e. Don't use the context from within a testing.Poll function.
func (*SSHClient) Conn ¶
func (c *SSHClient) Conn() *grpc.ClientConn
Conn returns a gRPC connection.