Files
threshold/internal/session/connection_closed_with.go
T
Louis Ruch 178d4efa64 ICU-745/Refactor internal/session to new domain errors (#877)
* Refactor internal/sessions to use domain errors
2021-02-03 16:25:56 -08:00

27 lines
689 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 uint64
BytesDown uint64
ClosedReason ClosedReason
}
func (c CloseWith) validate() error {
const op = "session.(CloseWith).validate"
if c.ConnectionId == "" {
return errors.New(errors.InvalidParameter, op, "missing connection id")
}
if c.ClosedReason.String() == "" {
return errors.New(errors.InvalidParameter, op, "missing closed reason")
}
// 0 is valid for BytesUp and BytesDown
return nil
}