Files
threshold/internal/session/connection_closed_with.go
T
Hugo Vieira d206635d74 fix(connection): Make bytes up and down a signed 64-bit integer
This fixes a theoretical issue with database interaction. Because the
fields in the database are signed 64-bit integers, it's theoretically
possible to overflow them if we're using unsigned 64-bit integers in the
application code.
2022-10-26 17:44:28 +01:00

27 lines
707 B
Go

package session
import (
"github.com/hashicorp/boundary/internal/errors"
)
// CloseWith defines the boundary data that is saved in the repo when the
// worker closes a connection between the client and the endpoint.
type CloseWith struct {
ConnectionId string
BytesUp int64
BytesDown int64
ClosedReason ClosedReason
}
func (c CloseWith) validate() error {
const op = "session.(CloseWith).validate"
if c.ConnectionId == "" {
return errors.NewDeprecated(errors.InvalidParameter, op, "missing connection id")
}
if c.ClosedReason.String() == "" {
return errors.NewDeprecated(errors.InvalidParameter, op, "missing closed reason")
}
// 0 is valid for BytesUp and BytesDown
return nil
}