Files
threshold/internal/session/term_reason.go
shadowdaoandClaude Sonnet 5.5 962d708fdd Rename Go module paths to repo.anhonesthost.net/CyberCoveLLC/threshold
Rename root, api and sdk module paths (imports, go.mod, go_package,
ldflags, build scripts, buf configs) and regenerate protobuf/gateway
code with the project's pinned toolchain. Wire identifiers unchanged.
api gets a local replace for sdk; root/api/sdk require v0.1.0.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-12 10:33:41 -07:00

53 lines
1.4 KiB
Go

// Copyright IBM Corp. 2020, 2026
// SPDX-License-Identifier: BUSL-1.1
package session
import (
"context"
"fmt"
"repo.anhonesthost.net/CyberCoveLLC/threshold/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(ctx context.Context, s string) (TerminationReason, error) {
const op = "session.convertToReason"
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 "", errors.New(ctx, errors.InvalidParameter, op, fmt.Sprintf("%s is not a valid reason", s))
}
}