Skip to content

Commit

Permalink
optimize: add global descriptor release api (#249)
Browse files Browse the repository at this point in the history
Co-authored-by: 吴骏逸 <[email protected]>
  • Loading branch information
wujunyi792 and 吴骏逸 authored Dec 26, 2024
1 parent a8df881 commit f616652
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions thrift_reflection/descriptor_register.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,21 @@ func RegisterAST(ast *parser.Thrift) (*GlobalDescriptor, *FileDescriptor) {
return gd, fd
}

// ReleaseGlobalDescriptors release the global descriptor
func ReleaseGlobalDescriptors(gds ...*GlobalDescriptor) {
if len(gds) == 0 {
return
}
lock.Lock()
defer lock.Unlock()
for _, gd := range gds {
if gd == nil {
continue
}
delete(globalDescriptorMap, gd.uuid)
}
}

func generateShortUUID() string {
uuid := make([]byte, 4)
_, _ = rand.Read(uuid)
Expand Down

0 comments on commit f616652

Please sign in to comment.