Files
threshold/internal/session/term_reason.go
T
Michael GaffneyandJeff Mitchell 94cb79bbdd See how Boundary would look with gofumpt applied (#853)
* See how Boundary would look with https://github.com/mvdan/gofumpt applied

Results of running `gofumpt -w -s .`

* Update tools file and Makefile for gofumpt

Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
2021-01-07 10:02:32 -05:00

48 lines
1.3 KiB
Go

package session
import (
"fmt"
"github.com/hashicorp/boundary/internal/errors"
)
// TerminationReason of the session
type TerminationReason string
const (
UnknownTermination TerminationReason = "unknown"
TimedOut TerminationReason = "timed out"
ClosedByUser TerminationReason = "closed by end-user"
Terminated TerminationReason = "terminated"
NetworkError TerminationReason = "network error"
SystemError TerminationReason = "system error"
ConnectionLimit TerminationReason = "connection limit"
SessionCanceled TerminationReason = "canceled"
)
// String representation of the termination reason
func (r TerminationReason) String() string {
return string(r)
}
func convertToReason(s string) (TerminationReason, error) {
switch s {
case UnknownTermination.String():
return UnknownTermination, nil
case TimedOut.String():
return TimedOut, nil
case ClosedByUser.String():
return ClosedByUser, nil
case Terminated.String():
return Terminated, nil
case NetworkError.String():
return NetworkError, nil
case SystemError.String():
return SystemError, nil
case ConnectionLimit.String():
return ConnectionLimit, nil
default:
return "", fmt.Errorf("termination reason: %s is not a valid reason: %w", s, errors.ErrInvalidParameter)
}
}