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>
60 lines
1.4 KiB
Go
60 lines
1.4 KiB
Go
// Copyright IBM Corp. 2020, 2026
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package session
|
|
|
|
import (
|
|
"context"
|
|
|
|
"repo.anhonesthost.net/CyberCoveLLC/threshold/globals"
|
|
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/db"
|
|
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/errors"
|
|
)
|
|
|
|
const (
|
|
// StatePrefix for state PK ids
|
|
StatePrefix = "ss"
|
|
|
|
// ConnectionPrefix for connection PK ids
|
|
ConnectionPrefix = "sc"
|
|
|
|
// ConnectionStatePrefix for connection state PK ids
|
|
ConnectionStatePrefix = "scs"
|
|
)
|
|
|
|
func newId(ctx context.Context) (string, error) {
|
|
const op = "session.newId"
|
|
id, err := db.NewPublicId(ctx, globals.SessionPrefix)
|
|
if err != nil {
|
|
return "", errors.Wrap(ctx, err, op)
|
|
}
|
|
return id, nil
|
|
}
|
|
|
|
func newStateId(ctx context.Context) (string, error) {
|
|
const op = "session.newStateId"
|
|
id, err := db.NewPublicId(ctx, StatePrefix)
|
|
if err != nil {
|
|
return "", errors.Wrap(ctx, err, op)
|
|
}
|
|
return id, nil
|
|
}
|
|
|
|
func newConnectionId(ctx context.Context) (string, error) {
|
|
const op = "session.newConnectionId"
|
|
id, err := db.NewPublicId(ctx, ConnectionPrefix)
|
|
if err != nil {
|
|
return "", errors.Wrap(ctx, err, op)
|
|
}
|
|
return id, nil
|
|
}
|
|
|
|
func newConnectionStateId(ctx context.Context) (string, error) {
|
|
const op = "session.newConnectionStateId"
|
|
id, err := db.NewPublicId(ctx, ConnectionStatePrefix)
|
|
if err != nil {
|
|
return "", errors.Wrap(ctx, err, op)
|
|
}
|
|
return id, nil
|
|
}
|