diff --git a/internal/session/ids.go b/internal/session/ids.go index 4b32cd84d8..5142503650 100644 --- a/internal/session/ids.go +++ b/internal/session/ids.go @@ -12,6 +12,9 @@ const ( // StatePrefix for state PK ids StatePrefix = "ss" + + // ConnectionPrefix for connection PK ids + ConnectionPrefix = "sc" ) func newId() (string, error) { @@ -29,3 +32,11 @@ func newStateId() (string, error) { } return id, nil } + +func newConnectionId() (string, error) { + id, err := db.NewPublicId(ConnectionPrefix) + if err != nil { + return "", fmt.Errorf("new session connection id: %w", err) + } + return id, nil +} diff --git a/internal/session/ids_test.go b/internal/session/ids_test.go index 44d48d323c..4c83f2847f 100644 --- a/internal/session/ids_test.go +++ b/internal/session/ids_test.go @@ -20,4 +20,9 @@ func Test_Ids(t *testing.T) { require.NoError(t, err) assert.True(t, strings.HasPrefix(id, StatePrefix+"_")) }) + t.Run("sc", func(t *testing.T) { + id, err := newConnectionId() + require.NoError(t, err) + assert.True(t, strings.HasPrefix(id, ConnectionPrefix+"_")) + }) }