func Fprint(w io.Writer, filename string) error
Fprint reads the entries from filename and writes them to w in human-readable form. It is intended for debugging.
func FprintReader(w io.Writer, r io.Reader) error
FprintReader reads the entries from r and writes them to w in human-readable form. It is intended for debugging.
A Recorder records RPCs for later playback.
type Recorder struct { // BeforeFunc defines a function that can inspect and modify requests and responses // written to the replay file. It does not modify messages sent to the service. // It is run once before a request is written to the replay file, and once before a response // is written to the replay file. // The function is called with the method name and the message that triggered the callback. // If the function returns an error, the error will be returned to the client. // This is only executed for unary RPCs; streaming RPCs are not supported. BeforeFunc func(string, proto.Message) error // contains filtered or unexported fields }
func NewRecorder(filename string, initial []byte) (*Recorder, error)
NewRecorder creates a recorder that writes to filename. The file will also store the initial bytes for retrieval during replay.
You must call Close on the Recorder to ensure that all data is written.
func NewRecorderWriter(w io.Writer, initial []byte) (*Recorder, error)
NewRecorderWriter creates a recorder that writes to w. The initial bytes will also be written to w for retrieval during replay.
You must call Close on the Recorder to ensure that all data is written.
func (r *Recorder) Close() error
Close saves any unwritten information.
func (r *Recorder) DialOptions() []grpc.DialOption
DialOptions returns the options that must be passed to grpc.Dial to enable recording.
A Replayer replays a set of RPCs saved by a Recorder.
type Replayer struct { // BeforeFunc defines a function that can inspect and modify requests before they // are matched for responses from the replay file. // The function is called with the method name and the message that triggered the callback. // If the function returns an error, the error will be returned to the client. // This is only executed for unary RPCs; streaming RPCs are not supported. BeforeFunc func(string, proto.Message) error // contains filtered or unexported fields }
func NewReplayer(filename string) (*Replayer, error)
NewReplayer creates a Replayer that reads from filename.
func NewReplayerReader(r io.Reader) (*Replayer, error)
NewReplayerReader creates a Replayer that reads from r.
func (rep *Replayer) Close() error
Close closes the Replayer.
func (rep *Replayer) Connection() (*grpc.ClientConn, error)
Connection returns a fake gRPC connection suitable for replaying.
func (rep *Replayer) DialOptions() []grpc.DialOption
DialOptions returns the options that must be passed to grpc.Dial to enable replaying.
func (rep *Replayer) Initial() []byte
Initial returns the initial state saved by the Recorder.
func (rep *Replayer) SetLogFunc(f func(format string, v ...interface{}))
SetLogFunc sets a function to be used for debug logging. The function should be safe to be called from multiple goroutines.