go.temporal.io/server/common/primitives/uuid.go

152 LOC · 53 covered · 99 uncovered · 20 ranges · 4170 concepts · 11 introducers · 2469 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the filego.temporal.io/server/common/persistence/cassandra/history_store.go · 431 LOCcassandra/history_store.…go.temporal.io/server/common/persistence/sql/metadata.go · 291 LOCsql/metadata.gogo.temporal.io/server/common/persistence/sql/nexus_endpoint_store.go · 230 LOCsql/nexus_endpoint_store…TestUpdate_NotZombie · 0 introduced LOCTestUpdate_NotZombieTestSet_Conflict · 0 introduced LOCTestSet_ConflictTestCreate_Reuse_CurrentConflict · 0 introduced LOCTestCreate_Reuse_Current…TestCreate_BrandNew_CurrentConflict · 0 introduced LOCTestCreate_BrandNew_Curr…TestSet · 0 introduced LOCTestSetTestCreate_ClosedWorkflow_Bypass · 0 introduced LOCTestCreate_ClosedWorkflo…TestCreate_Reuse · 0 introduced LOCTestCreate_ReuseTestCreate_Zombie · 0 introduced LOCTestCreate_ZombieTestCreate_ClosedWorkflow_UpdateCurrent · 0 introduced LOCTestCreate_ClosedWorkflo…TestCreate_ClosedWorkflow_BrandNew · 0 introduced LOCTestCreate_ClosedWorkflo…TestCreate_BrandNew · 0 introduced LOCTestCreate_BrandNewTestDeleteNamespace · 0 introduced LOCTestDeleteNamespaceTestDeleteNamespace · 0 introduced LOCTestDeleteNamespaceTestConcurrentCreateNamespace · 0 introduced LOCTestConcurrentCreateName…TestCreateNamespaceWithDuplicateID · 0 introduced LOCTestCreateNamespaceWithD…TestConcurrentCreateNamespace · 0 introduced LOCTestConcurrentCreateName…TestCreateNamespaceWithDuplicateID · 0 introduced LOCTestCreateNamespaceWithD…TestDeleteNamespace · 0 introduced LOCTestDeleteNamespaceTestConcurrentCreateNamespace · 0 introduced LOCTestConcurrentCreateName…TestCreateNamespaceWithDuplicateID · 0 introduced LOCTestCreateNamespaceWithD…TestDeleteNamespace · 0 introduced LOCTestDeleteNamespaceTestInitializeSystemNamespaces · 0 introduced LOCTestInitializeSystemName…TestInitializeSystemNamespaces · 0 introduced LOCTestInitializeSystemName…TestConcurrentCreateNamespace · 0 introduced LOCTestConcurrentCreateName…TestCreateNamespaceWithDuplicateID · 0 introduced LOCTestCreateNamespaceWithD…TestDeleteNamespace · 0 introduced LOCTestDeleteNamespaceTestInitializeSystemNamespaces · 0 introduced LOCTestInitializeSystemName…TestConcurrentCreateNamespace · 0 introduced LOCTestConcurrentCreateName…TestCreateNamespaceWithDuplicateID · 0 introduced LOCTestCreateNamespaceWithD…TestRenameNamespaceNotFound · 0 introduced LOCTestRenameNamespaceNotFo…TestInitializeSystemNamespaces · 0 introduced LOCTestInitializeSystemName…TestRenameNamespaceNotFound · 0 introduced LOCTestRenameNamespaceNotFo…TestInitializeSystemNamespaces · 0 introduced LOCTestInitializeSystemName…TestRenameNamespaceNotFound · 0 introduced LOCTestRenameNamespaceNotFo…TestRenameNamespaceNotFound · 0 introduced LOCTestRenameNamespaceNotFo…TestRenameNamespaceNotFound · 0 introduced LOCTestRenameNamespaceNotFo…metadata.go ×1 · 4 introduced LOCmetadata.go ×1history_store.go ×11 · 51 introduced LOChistory_store.go ×11namespace.go ×1 · 1 introduced LOCnamespace.go ×1namespace.go ×1 · 7 introduced LOCnamespace.go ×1namespace.go ×1 · 3 introduced LOCnamespace.go ×1namespace.go ×1 · 1 introduced LOCnamespace.go ×1namespace.go ×1 · 7 introduced LOCnamespace.go ×1namespace.go ×1 · 12 introduced LOCnamespace.go ×1nexus_endpoint_store.go ×1 · 7 introduced LOCnexus_endpoint_store.go …namespace.go ×1 · 7 introduced LOCnamespace.go ×1namespace.go ×1 · 1 introduced LOCnamespace.go ×1namespace.go ×1 · 12 introduced LOCnamespace.go ×1uuid.go ×3 · 6 introduced LOCuuid.go ×3uuid.go ×1 · 3 introduced LOCuuid.go ×1uuid.go ×2 · 4 introduced LOCuuid.go ×2uuid.go ×1 · 2 introduced LOCuuid.go ×1uuid.go ×1 · 4 introduced LOCuuid.go ×1uuid.go ×3 · 16 introduced LOCuuid.go ×3uuid.go ×2 · 4 introduced LOCuuid.go ×2uuid.go ×2 · 4 introduced LOCuuid.go ×2TestCreate_BrandNew · introduced test · go.temporal.io/server/common/persistence/tests/TestCassandraExecutionMutableStateStoreSuite/TestCreate_BrandNewTestCreate_BrandNewTestCreate_BrandNew_CurrentConflict · introduced test · go.temporal.io/server/common/persistence/tests/TestCassandraExecutionMutableStateStoreSuite/TestCreate_BrandNew_CurrentConflictTestCreate_BrandNew_Curr…TestCreate_ClosedWorkflow_BrandNew · introduced test · go.temporal.io/server/common/persistence/tests/TestCassandraExecutionMutableStateStoreSuite/TestCreate_ClosedWorkflow_BrandNewTestCreate_ClosedWorkflo…TestCreate_ClosedWorkflow_Bypass · introduced test · go.temporal.io/server/common/persistence/tests/TestCassandraExecutionMutableStateStoreSuite/TestCreate_ClosedWorkflow_BypassTestCreate_ClosedWorkflo…TestCreate_ClosedWorkflow_UpdateCurrent · introduced test · go.temporal.io/server/common/persistence/tests/TestCassandraExecutionMutableStateStoreSuite/TestCreate_ClosedWorkflow_UpdateCurrentTestCreate_ClosedWorkflo…TestCreate_Reuse · introduced test · go.temporal.io/server/common/persistence/tests/TestCassandraExecutionMutableStateStoreSuite/TestCreate_ReuseTestCreate_ReuseTestCreate_Reuse_CurrentConflict · introduced test · go.temporal.io/server/common/persistence/tests/TestCassandraExecutionMutableStateStoreSuite/TestCreate_Reuse_CurrentConflictTestCreate_Reuse_Current…TestCreate_Zombie · introduced test · go.temporal.io/server/common/persistence/tests/TestCassandraExecutionMutableStateStoreSuite/TestCreate_ZombieTestCreate_ZombieTestSet · introduced test · go.temporal.io/server/common/persistence/tests/TestCassandraExecutionMutableStateStoreSuite/TestSetTestSetTestSet_Conflict · introduced test · go.temporal.io/server/common/persistence/tests/TestCassandraExecutionMutableStateStoreSuite/TestSet_ConflictTestSet_ConflictTestUpdate_NotZombie · introduced test · go.temporal.io/server/common/persistence/tests/TestCassandraExecutionMutableStateStoreSuite/TestUpdate_NotZombieTestUpdate_NotZombieTestConcurrentCreateNamespace · introduced test · go.temporal.io/server/common/persistence/tests/TestMySQLMetadataPersistenceSuiteV2/TestConcurrentCreateNamespaceTestConcurrentCreateName…TestCreateNamespaceWithDuplicateID · introduced test · go.temporal.io/server/common/persistence/tests/TestMySQLMetadataPersistenceSuiteV2/TestCreateNamespaceWithDuplicateIDTestCreateNamespaceWithD…TestDeleteNamespace · introduced test · go.temporal.io/server/common/persistence/tests/TestMySQLMetadataPersistenceSuiteV2/TestDeleteNamespaceTestDeleteNamespaceTestInitializeSystemNamespaces · introduced test · go.temporal.io/server/common/persistence/tests/TestMySQLMetadataPersistenceSuiteV2/TestInitializeSystemNamespacesTestInitializeSystemName…TestRenameNamespaceNotFound · introduced test · go.temporal.io/server/common/persistence/tests/TestMySQLMetadataPersistenceSuiteV2/TestRenameNamespaceNotFoundTestRenameNamespaceNotFo…TestConcurrentCreateNamespace · introduced test · go.temporal.io/server/common/persistence/tests/TestPGX/TestPostgreSQLMetadataPersistenceSuiteV2/TestConcurrentCreateNamespaceTestConcurrentCreateName…TestCreateNamespaceWithDuplicateID · introduced test · go.temporal.io/server/common/persistence/tests/TestPGX/TestPostgreSQLMetadataPersistenceSuiteV2/TestCreateNamespaceWithDuplicateIDTestCreateNamespaceWithD…TestDeleteNamespace · introduced test · go.temporal.io/server/common/persistence/tests/TestPGX/TestPostgreSQLMetadataPersistenceSuiteV2/TestDeleteNamespaceTestDeleteNamespaceTestInitializeSystemNamespaces · introduced test · go.temporal.io/server/common/persistence/tests/TestPGX/TestPostgreSQLMetadataPersistenceSuiteV2/TestInitializeSystemNamespacesTestInitializeSystemName…TestRenameNamespaceNotFound · introduced test · go.temporal.io/server/common/persistence/tests/TestPGX/TestPostgreSQLMetadataPersistenceSuiteV2/TestRenameNamespaceNotFoundTestRenameNamespaceNotFo…TestConcurrentCreateNamespace · introduced test · go.temporal.io/server/common/persistence/tests/TestPQ/TestPostgreSQLMetadataPersistenceSuiteV2/TestConcurrentCreateNamespaceTestConcurrentCreateName…TestCreateNamespaceWithDuplicateID · introduced test · go.temporal.io/server/common/persistence/tests/TestPQ/TestPostgreSQLMetadataPersistenceSuiteV2/TestCreateNamespaceWithDuplicateIDTestCreateNamespaceWithD…TestDeleteNamespace · introduced test · go.temporal.io/server/common/persistence/tests/TestPQ/TestPostgreSQLMetadataPersistenceSuiteV2/TestDeleteNamespaceTestDeleteNamespaceTestInitializeSystemNamespaces · introduced test · go.temporal.io/server/common/persistence/tests/TestPQ/TestPostgreSQLMetadataPersistenceSuiteV2/TestInitializeSystemNamespacesTestInitializeSystemName…TestRenameNamespaceNotFound · introduced test · go.temporal.io/server/common/persistence/tests/TestPQ/TestPostgreSQLMetadataPersistenceSuiteV2/TestRenameNamespaceNotFoundTestRenameNamespaceNotFo…TestConcurrentCreateNamespace · introduced test · go.temporal.io/server/common/persistence/tests/TestSQLiteFileMetadataPersistenceSuiteV2/TestConcurrentCreateNamespaceTestConcurrentCreateName…TestCreateNamespaceWithDuplicateID · introduced test · go.temporal.io/server/common/persistence/tests/TestSQLiteFileMetadataPersistenceSuiteV2/TestCreateNamespaceWithDuplicateIDTestCreateNamespaceWithD…TestDeleteNamespace · introduced test · go.temporal.io/server/common/persistence/tests/TestSQLiteFileMetadataPersistenceSuiteV2/TestDeleteNamespaceTestDeleteNamespaceTestInitializeSystemNamespaces · introduced test · go.temporal.io/server/common/persistence/tests/TestSQLiteFileMetadataPersistenceSuiteV2/TestInitializeSystemNamespacesTestInitializeSystemName…TestRenameNamespaceNotFound · introduced test · go.temporal.io/server/common/persistence/tests/TestSQLiteFileMetadataPersistenceSuiteV2/TestRenameNamespaceNotFoundTestRenameNamespaceNotFo…TestConcurrentCreateNamespace · introduced test · go.temporal.io/server/common/persistence/tests/TestSQLiteMetadataPersistenceSuiteV2/TestConcurrentCreateNamespaceTestConcurrentCreateName…TestCreateNamespaceWithDuplicateID · introduced test · go.temporal.io/server/common/persistence/tests/TestSQLiteMetadataPersistenceSuiteV2/TestCreateNamespaceWithDuplicateIDTestCreateNamespaceWithD…TestDeleteNamespace · introduced test · go.temporal.io/server/common/persistence/tests/TestSQLiteMetadataPersistenceSuiteV2/TestDeleteNamespaceTestDeleteNamespaceTestInitializeSystemNamespaces · introduced test · go.temporal.io/server/common/persistence/tests/TestSQLiteMetadataPersistenceSuiteV2/TestInitializeSystemNamespacesTestInitializeSystemName…TestRenameNamespaceNotFound · introduced test · go.temporal.io/server/common/persistence/tests/TestSQLiteMetadataPersistenceSuiteV2/TestRenameNamespaceNotFoundTestRenameNamespaceNotFo…Focused file · go.temporal.io/server/common/primitives/uuid.go · 152 LOCprimitives/uuid.go

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 package primitives
2
3 import (
4 "database/sql/driver"
5 "encoding/hex"
6
7 guuid "github.com/google/uuid"
8 )
9
10 // UUID represents a 16-byte universally unique identifier
11 // this type is a wrapper around google/uuid with the following differences
12 // - type is a byte slice instead of [16]byte
13 // - db serialization converts uuid to bytes as opposed to string
14 type UUID []byte
15
16 // MustParseUUID returns a UUID parsed from the given string representation
17 // returns nil if the input is empty string
18 // panics if the given input is malformed
19 > func MustParseUUID(s string) UUID { uuid.go ×2
20 > if s == "" {
21 return nil
22 }
23 > u := guuid.MustParse(s) uuid.go ×2
24 > return u[:]
25 }
26
27 // ParseUUID returns a UUID parsed from the given string representation
28 // returns:
29 // - nil if the input is empty string
30 // - error if input is malformed
31 // - UUID object if input can be parsed and is valid
32 > func ParseUUID(s string) (UUID, error) { uuid.go ×1
33 > if s == "" {
34 > return nil, nil metadata.go ×1
35 > }
36 > u, err := guuid.Parse(s) uuid.go ×2
37 >
38 > if err != nil {
39 return nil, err
40 }
41 > return u[:], nil uuid.go ×2
42 }
43
44 // MustValidateUUID parses and validates UUID contents from the given string representation
45 // returns empty string if the input is empty string
46 // panics if the given input is malformed
47 > func MustValidateUUID(s string) string { uuid.go ×1
48 > MustParseUUID(s)
49 > return s
50 > }
51
52 // ValidateUUID parses and validates UUID contents from the given string representation
53 // returns:
54 // - nil if the input is empty string
55 // - error if input is malformed
56 // - input if input can be parsed and is valid
57 > func ValidateUUID(s string) (string, error) { history_store.go ×11
58 > if s == "" {
59 return "", nil
60 }
61 > _, err := guuid.Parse(s) history_store.go ×11
62 > if err != nil {
63 return "", err
64 }
65
66 > return s, nil history_store.go ×11
67 }
68
69 // NewUUID generates a new random UUID
70 > func NewUUID() UUID { uuid.go ×2
71 > u, err := guuid.NewV7()
72 > if err != nil {
73 // Should never happen, but this matches the behavior of google/uuid.NewRandom
74 return nil
75 }
76 > return u[:] uuid.go ×2
77 }
78
79 // Downcast returns the UUID as a byte slice. This is necessary when passing to type sensitive interfaces such as cql.
80 func (u UUID) Downcast() []byte {
81 return u
82 }
83
84 // UUIDPtr simply returns a pointer for the given value type
85 //
86 //go:fix inline
87 func UUIDPtr(u UUID) *UUID {
88 return new(u)
89 }
90
91 // String returns the 36 byte hexstring representation of this uuid
92 // return empty string if this uuid is nil
93 > func (u UUID) String() string { uuid.go ×3
94 > if len(u) != 16 {
95 return ""
96 }
97 > var buf [36]byte uuid.go ×3
98 > u.encodeHex(buf[:])
99 > return string(buf[:])
100 }
101
102 // StringPtr returns a pointer to the 36 byte hexstring representation of this uuid
103 // return empty string if this uuid is nil
104 func (u UUID) StringPtr() *string {
105 if len(u) != 16 {
106 return new("")
107 }
108 var buf [36]byte
109 u.encodeHex(buf[:])
110 return new(string(buf[:]))
111 }
112
113 > func UUIDString(b []byte) string { nexus_endpoint_store.go ×1
114 > return UUID(b).String()
115 > }
116
117 //go:fix inline
118 func stringPtr(v string) *string {
119 return new(v)
120 }
121
122 // Scan implements sql.Scanner interface to allow this type to be
123 // parsed transparently by database drivers
124 > func (u *UUID) Scan(src any) error { uuid.go ×3
125 > if src == nil {
126 return nil
127 }
128 > guuid := &guuid.UUID{} uuid.go ×3
129 > if err := guuid.Scan(src); err != nil {
130 return err
131 }
132 > *u = (*guuid)[:] uuid.go ×3
133 > return nil
134 }
135
136 // Value implements sql.Valuer so that UUIDs can be written to databases
137 // transparently. This method returns a byte slice representation of uuid
138 > func (u UUID) Value() (driver.Value, error) { uuid.go ×1
139 > return []byte(u), nil
140 > }
141
142 > func (u UUID) encodeHex(dst []byte) { uuid.go ×3
143 > hex.Encode(dst, u[:4])
144 > dst[8] = '-'
145 > hex.Encode(dst[9:13], u[4:6])
146 > dst[13] = '-'
147 > hex.Encode(dst[14:18], u[6:8])
148 > dst[18] = '-'
149 > hex.Encode(dst[19:23], u[8:10])
150 > dst[23] = '-'
151 > hex.Encode(dst[24:], u[10:])
152 > }