Rename Results encoding functions
This commit is contained in:
@@ -68,7 +68,7 @@ func attack(rate uint64, duration time.Duration, targetsf, ordering, output stri
|
||||
results := vegeta.Attack(targets, rate, duration)
|
||||
log.Println("Done!")
|
||||
log.Printf("Writing results to '%s'...", output)
|
||||
if err := results.WriteTo(out); err != nil {
|
||||
if err := results.Encode(out); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -22,15 +22,15 @@ type Result struct {
|
||||
// decoding and sorting behavior attached
|
||||
type Results []Result
|
||||
|
||||
// WriteTo encodes the results and writes it to an io.Writer
|
||||
// Encode encodes the results and writes it to an io.Writer
|
||||
// returning an error in case of failure
|
||||
func (r Results) WriteTo(out io.Writer) error {
|
||||
func (r Results) Encode(out io.Writer) error {
|
||||
return gob.NewEncoder(out).Encode(r)
|
||||
}
|
||||
|
||||
// ReadFrom reads data from an io.Reader and decodes it into a Results struct
|
||||
// Decode reads data from an io.Reader and decodes it into a Results struct
|
||||
// returning an error in case of failure
|
||||
func (r *Results) ReadFrom(in io.Reader) error {
|
||||
func (r *Results) Decode(in io.Reader) error {
|
||||
return gob.NewDecoder(in).Decode(r)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,12 +15,12 @@ func TestEncoding(t *testing.T) {
|
||||
}
|
||||
buffer := &bytes.Buffer{}
|
||||
|
||||
if err := results.WriteTo(buffer); err != nil {
|
||||
if err := results.Encode(buffer); err != nil {
|
||||
t.Fatalf("Failed WriteTo: %s", err)
|
||||
}
|
||||
|
||||
decoded := Results{}
|
||||
if err := decoded.ReadFrom(buffer); err != nil {
|
||||
if err := decoded.Decode(buffer); err != nil {
|
||||
t.Fatalf("Failed ReadFrom: %s", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user