Files
threshold/internal/session/ids.go
T

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

57 lines
1.2 KiB
Go
Raw Normal View History

2020-09-16 12:02:02 -04:00
// Copyright (c) HashiCorp, Inc.
2023-02-02 17:15:17 -08:00
// SPDX-License-Identifier: MPL-2.0
2020-09-16 12:02:02 -04:00
package session
import (
"github.com/hashicorp/boundary/globals"
2020-09-16 12:02:02 -04:00
"github.com/hashicorp/boundary/internal/db"
"github.com/hashicorp/boundary/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() (string, error) {
const op = "session.newId"
id, err := db.NewPublicId(globals.SessionPrefix)
2020-09-16 12:02:02 -04:00
if err != nil {
return "", errors.WrapDeprecated(err, op)
2020-09-16 12:02:02 -04:00
}
return id, nil
}
func newStateId() (string, error) {
const op = "session.newStateId"
2020-09-16 12:02:02 -04:00
id, err := db.NewPublicId(StatePrefix)
if err != nil {
return "", errors.WrapDeprecated(err, op)
2020-09-16 12:02:02 -04:00
}
return id, nil
}
func newConnectionId() (string, error) {
const op = "session.newConnectionId"
2020-09-16 12:02:02 -04:00
id, err := db.NewPublicId(ConnectionPrefix)
if err != nil {
return "", errors.WrapDeprecated(err, op)
2020-09-16 12:02:02 -04:00
}
return id, nil
}
func newConnectionStateId() (string, error) {
const op = "session.newConnectionStateId"
2020-09-16 12:02:02 -04:00
id, err := db.NewPublicId(ConnectionStatePrefix)
if err != nil {
return "", errors.WrapDeprecated(err, op)
2020-09-16 12:02:02 -04:00
}
return id, nil
}