Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita14b5da

Browse files
committed
review 1: db migration comment, api key uuid values in test
1 parentbe19ef2 commita14b5da

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
-- column is nullable to not break interceptions recorded before this column was added
12
ALTERTABLE aibridge_interceptions ADD COLUMN api_key_idtext;

‎enterprise/aibridged/pool.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (p *CachedBridgePool) Acquire(ctx context.Context, req Request, clientFn Cl
112112
deferp.cache.Wait()
113113

114114
// Fast path.
115-
cacheKey:=req.InitiatorID.String()+req.APIKeyID
115+
cacheKey:=req.InitiatorID.String()+"|"+req.APIKeyID
116116
bridge,ok:=p.cache.Get(cacheKey)
117117
ifok&&bridge!=nil {
118118
// TODO: future improvement:

‎enterprise/aibridged/pool_test.go‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestPool(t *testing.T) {
3434
require.NoError(t,err)
3535
t.Cleanup(func() {pool.Shutdown(context.Background()) })
3636

37-
id,id2:=uuid.New(),uuid.New()
37+
id,id2,apiKeyID1,apiKeyID2:=uuid.New(),uuid.New(),uuid.New(),uuid.New()
3838
clientFn:=func() (aibridged.DRPCClient,error) {
3939
returnclient,nil
4040
}
@@ -50,15 +50,15 @@ func TestPool(t *testing.T) {
5050
inst,err:=pool.Acquire(t.Context(), aibridged.Request{
5151
SessionKey:"key",
5252
InitiatorID:id,
53-
APIKeyID:"apiKeyId",
53+
APIKeyID:apiKeyID1.String(),
5454
},clientFn,newMockMCPFactory(mcpProxy))
5555
require.NoError(t,err,"acquire pool instance")
5656

5757
// ...and it will return it when acquired again.
5858
instB,err:=pool.Acquire(t.Context(), aibridged.Request{
5959
SessionKey:"key",
6060
InitiatorID:id,
61-
APIKeyID:"apiKeyId",
61+
APIKeyID:apiKeyID1.String(),
6262
},clientFn,newMockMCPFactory(mcpProxy))
6363
require.NoError(t,err,"acquire pool instance")
6464
require.Same(t,inst,instB)
@@ -76,7 +76,7 @@ func TestPool(t *testing.T) {
7676
inst2,err:=pool.Acquire(t.Context(), aibridged.Request{
7777
SessionKey:"key",
7878
InitiatorID:id2,
79-
APIKeyID:"apiKeyId",
79+
APIKeyID:apiKeyID1.String(),
8080
},clientFn,newMockMCPFactory(mcpProxy))
8181
require.NoError(t,err,"acquire pool instance")
8282
require.NotSame(t,inst,inst2)
@@ -87,13 +87,14 @@ func TestPool(t *testing.T) {
8787
require.EqualValues(t,1,metrics.Hits())
8888
require.EqualValues(t,2,metrics.Misses())
8989

90-
//Different instance is returned for different api key id
90+
//This will get called again because a new instance will be created.
9191
mcpProxy.EXPECT().Init(gomock.Any()).Times(1).Return(nil)
9292

93+
// New instance is created for different api key id
9394
inst2B,err:=pool.Acquire(t.Context(), aibridged.Request{
9495
SessionKey:"key",
9596
InitiatorID:id2,
96-
APIKeyID:"newApiKeyId",
97+
APIKeyID:apiKeyID2.String(),
9798
},clientFn,newMockMCPFactory(mcpProxy))
9899
require.NoError(t,err,"acquire pool instance 2B")
99100
require.NotSame(t,inst2,inst2B)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp