Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unused serialization functions, add one #29

Merged
merged 2 commits into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
)

//go:generate stringer -type=Method -linecomment
//go:generate msgp
//msgp:ignore Method

// Archive represents a metric archive
// the zero value represents a raw metric
Expand Down
59 changes: 59 additions & 0 deletions archive_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions archive_gen_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 0 additions & 42 deletions key.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,12 @@ import (
"fmt"
"strconv"
"strings"

"github.com/tinylib/msgp/msgp"
)

//go:generate msgp
//msgp:ignore AMKey
// don't ignore Key, MKey because it's used for MetricDefinition

// A random number that does not conflict with any of the msgp internal
// types, and which is also not the first one after the msgp internal types
// to avoid accidental conflicts with other custom types
const msgpExtensionId = 97

func init() {
msgp.RegisterExtension(msgpExtensionId, func() msgp.Extension { return new(AMKey) })
}

var ErrStringTooShort = errors.New("string too short")
var ErrInvalidFormat = errors.New("invalid format")

Expand Down Expand Up @@ -77,37 +66,6 @@ type AMKey struct {
Archive Archive
}

// ExtensionType is part of the msgp.Extension interface
func (a *AMKey) ExtensionType() int8 {
return msgpExtensionId
}

// Len is part of the msgp.Extension interface
// It returns the length of the encoded byte slice representing this AMKey
// Length is variable because the AMKey may include the span & method,
// also the org id can have a varying number of digits
func (a *AMKey) Len() int {
return len(a.String())
}

// MarshalBinaryTo is part of the msgp.Extension interface
// It takes a buffer which must have the length returned by the Len() function
// and writes the encoded version of this AMKey into it
func (a *AMKey) MarshalBinaryTo(buf []byte) error {
copy(buf, a.String())

return nil
}

// UnmarshalBinary is part of the msgp.Extension interface
// It takes a buffer containing an encoded AMKey and decodes it into this
// AMKey instance
func (a *AMKey) UnmarshalBinary(buf []byte) error {
var err error
*a, err = AMKeyFromString(string(buf))
return err
}

func (a AMKey) String() string {
if a.Archive == 0 {
return a.MKey.String()
Expand Down