Documentation
¶
Overview ¶
Package grpc implements a protocol.Protocol driver for gRPC.
VegaLoad has no compiled proto stubs for whatever service a scenario targets — asking an author to generate and vendor them just to load test a service would fight the "every test is a file" principle in AGENTS.md. Instead this driver sends target.Body as an already-encoded message verbatim and hands back the response the same way, using a pass-through codec instead of protobuf's. The scripting layer (built later in Phase 0) is what will give a scenario author a convenient way to produce those bytes; this driver only needs to move them.
Index ¶
Constants ¶
const ( EncodingJSON = "json" EncodingBase64 = "base64" )
Encodings of a script call's body and reply.
Variables ¶
var Options = slices.Clone(tlsconf.Keys)
Options are the -opt keys this driver accepts.
Functions ¶
Types ¶
type Call ¶ added in v0.6.0
type Call struct {
// Method is the full method, "/pkg.Service/Method" (the leading slash
// is optional).
Method string
// Body is the request: JSON text, or base64 of the encoded message when
// Encoding is "base64". Empty JSON means an empty message.
Body []byte
// Encoding is "json" (the default) or "base64".
Encoding string
// Headers are sent as gRPC metadata.
Headers map[string]string
// Timeout bounds the whole call, reflection included. Zero means none.
Timeout time.Duration
}
Call is one unary call from a script.
type Conn ¶ added in v0.6.0
type Conn struct {
// contains filtered or unexported fields
}
Conn is a gRPC client for scripts. It dials lazily, keeps one connection for every call, and remembers each method's message types. It is safe for concurrent use.
func NewConn ¶ added in v0.6.0
NewConn returns a Conn for target (a bare host:port, grpc:// or grpcs://). It never fails because the server is unreachable, only for a bad target.
func NewConnWithFiles ¶ added in v0.8.0
NewConnWithFiles is NewConn with the shared TLS file options. The files are read here, when the connection is built.
func (*Conn) Do ¶ added in v0.6.0
Do makes the call. It returns an error only when the call is set up wrongly: a bad method name, an unknown method, a streaming method, a body that is not valid for the method's message, or a server that offers no reflection while the body is JSON. Everything the network or the server does is in the Reply.
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver is a gRPC protocol.Protocol. It dials once in New and reuses the same *grpc.ClientConn (and the HTTP/2 connection underneath it) across every call to Do.
func New ¶
New returns a ready-to-use Driver for target. target.URL is a bare "host:port", or "grpc://host:port" for the same thing written explicitly, or "grpcs://host:port" to dial over TLS. target.Method must be set to the full RPC method (e.g. "/package.Service/Method") — unlike the HTTP drivers there is no sensible default. timeout bounds each individual call.
New returns an error for anything that is a configuration problem (a missing Method, an unparseable target, an unsupported scheme) — never for the target being unreachable, which Do reports per call instead, since dialing is lazy.
type Reply ¶ added in v0.6.0
type Reply struct {
// Code is the gRPC status code (0, OK, when the call worked).
Code codes.Code
// Body is the reply: JSON text, or base64 when Encoding was "base64".
// It is empty when the call failed.
Body []byte
Err error
BytesSent int64
BytesReceived int64
}
Reply is what a call got back. A call the server answered with an error status, or that failed on the network, is a Reply with Err set, not a Go error: a script is expected to look at it.