2020-11-05 16:54:03 -05:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2020-09-18 18:12:41 -04:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-02-02 17:15:17 -08:00
|
|
|
|
2020-09-18 18:12:41 -04:00
|
|
|
package session
|
|
|
|
|
|
|
|
|
|
import (
|
2023-06-06 17:09:08 -04:00
|
|
|
"context"
|
|
|
|
|
|
2020-11-05 16:54:03 -05:00
|
|
|
"github.com/hashicorp/boundary/internal/errors"
|
2020-09-18 18:12:41 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 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 {
|
2020-09-21 00:09:50 -04:00
|
|
|
ConnectionId string
|
2022-10-06 17:37:50 +01:00
|
|
|
BytesUp int64
|
|
|
|
|
BytesDown int64
|
2020-09-21 00:09:50 -04:00
|
|
|
ClosedReason ClosedReason
|
2020-09-18 18:12:41 -04:00
|
|
|
}
|
|
|
|
|
|
2023-06-06 17:09:08 -04:00
|
|
|
func (c CloseWith) validate(ctx context.Context) error {
|
2021-02-03 16:25:56 -08:00
|
|
|
const op = "session.(CloseWith).validate"
|
2020-09-18 18:12:41 -04:00
|
|
|
if c.ConnectionId == "" {
|
2023-06-06 17:09:08 -04:00
|
|
|
return errors.New(ctx, errors.InvalidParameter, op, "missing connection id")
|
2020-09-18 18:12:41 -04:00
|
|
|
}
|
|
|
|
|
if c.ClosedReason.String() == "" {
|
2023-06-06 17:09:08 -04:00
|
|
|
return errors.New(ctx, errors.InvalidParameter, op, "missing closed reason")
|
2020-09-18 18:12:41 -04:00
|
|
|
}
|
|
|
|
|
// 0 is valid for BytesUp and BytesDown
|
|
|
|
|
return nil
|
|
|
|
|
}
|