Files
threshold/internal/session/connection_closed_reason.go
T
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

49 lines
1.3 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"
)
// ClosedReason of the connection
type ClosedReason string
const (
UnknownReason ClosedReason = "unknown"
ConnectionTimedOut ClosedReason = "timed out"
ConnectionClosedByUser ClosedReason = "closed by end-user"
ConnectionCanceled ClosedReason = "canceled"
ConnectionNetworkError ClosedReason = "network error"
ConnectionSystemError ClosedReason = "system error"
)
// String representation of the termination reason
func (r ClosedReason) String() string {
return string(r)
}
func convertToClosedReason(ctx context.Context, s string) (ClosedReason, error) {
const op = "session.convertToClosedReason"
switch s {
case UnknownReason.String():
return UnknownReason, nil
case ConnectionTimedOut.String():
return ConnectionTimedOut, nil
case ConnectionClosedByUser.String():
return ConnectionClosedByUser, nil
case ConnectionCanceled.String():
return ConnectionCanceled, nil
case ConnectionNetworkError.String():
return ConnectionNetworkError, nil
case ConnectionSystemError.String():
return ConnectionSystemError, nil
default:
return "", errors.New(ctx, errors.InvalidParameter, op, fmt.Sprintf("%s is not a valid reason", s))
}
}