Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

59 lines
1.4 KiB
Go
Raw Permalink Normal View History

// Copyright IBM Corp. 2020, 2026
2023-02-02 17:15:17 -08:00
// SPDX-License-Identifier: BUSL-1.1
2020-09-16 12:02:02 -04:00
package session
import (
"context"
"repo.anhonesthost.net/CyberCoveLLC/threshold/globals"
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/db"
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/errors"
2020-09-16 12:02:02 -04:00
)
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)
2020-09-16 12:02:02 -04:00
if err != nil {
return "", errors.Wrap(ctx, err, op)
2020-09-16 12:02:02 -04:00
}
return id, nil
}
func newStateId(ctx context.Context) (string, error) {
const op = "session.newStateId"
id, err := db.NewPublicId(ctx, StatePrefix)
2020-09-16 12:02:02 -04:00
if err != nil {
return "", errors.Wrap(ctx, err, op)
2020-09-16 12:02:02 -04:00
}
return id, nil
}
func newConnectionId(ctx context.Context) (string, error) {
const op = "session.newConnectionId"
id, err := db.NewPublicId(ctx, ConnectionPrefix)
2020-09-16 12:02:02 -04:00
if err != nil {
return "", errors.Wrap(ctx, err, op)
2020-09-16 12:02:02 -04:00
}
return id, nil
}
func newConnectionStateId(ctx context.Context) (string, error) {
const op = "session.newConnectionStateId"
id, err := db.NewPublicId(ctx, ConnectionStatePrefix)
2020-09-16 12:02:02 -04:00
if err != nil {
return "", errors.Wrap(ctx, err, op)
2020-09-16 12:02:02 -04:00
}
return id, nil
}