File tree Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -31,9 +31,11 @@ func (instance *Traceloop) populatePromptRegistry() {
31
31
return
32
32
}
33
33
34
+ instance .registryMutex .Lock ()
34
35
for _ , prompt := range response .Prompts {
35
36
instance .promptRegistry [prompt .Key ] = & prompt
36
37
}
38
+ instance .registryMutex .Unlock ()
37
39
}
38
40
39
41
func (instance * Traceloop ) pollPrompts () {
@@ -55,6 +57,8 @@ func (instance *Traceloop) pollPrompts() {
55
57
}
56
58
57
59
func (instance * Traceloop ) getPromptVersion (key string ) (* model.PromptVersion , error ) {
60
+ instance .registryMutex .RLock ()
61
+ defer instance .registryMutex .RUnlock ()
58
62
if instance .promptRegistry [key ] == nil {
59
63
return nil , fmt .Errorf ("prompt with key %s not found" , key )
60
64
}
Original file line number Diff line number Diff line change 6
6
"log"
7
7
"net/http"
8
8
"os"
9
+ "sync"
9
10
"time"
10
11
11
12
"go.opentelemetry.io/otel/attribute"
@@ -21,6 +22,7 @@ const PromptsPath = "/v1/traceloop/prompts"
21
22
type Traceloop struct {
22
23
config Config
23
24
promptRegistry model.PromptRegistry
25
+ registryMutex sync.RWMutex
24
26
tracerProvider * trace.TracerProvider
25
27
http.Client
26
28
}
You can’t perform that action at this time.
0 commit comments