• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / storage / 24368240723

13 Apr 2026 09:38PM UTC coverage: 81.027% (+0.04%) from 80.986%
24368240723

Pull #1017

github

web-flow
Merge 0ee93c4c0 into a49ab6a7b
Pull Request #1017: feat: add tenant config per request hit ratio

3284 of 4261 branches covered (77.07%)

Branch coverage included in aggregate %.

133 of 156 new or added lines in 30 files covered. (85.26%)

1 existing line in 1 file now uncovered.

30774 of 37772 relevant lines covered (81.47%)

318.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.63
/src/http/plugins/vector.ts
1
import { getTenantConfig, multitenantKnex } from '@internal/database'
1✔
2
import { ERRORS } from '@internal/errors'
1✔
3
import { KnexShardStoreFactory, ShardCatalog, SingleShard } from '@internal/sharding'
1✔
4
import {
1✔
5
  createS3VectorClient,
1✔
6
  KnexVectorMetadataDB,
1✔
7
  S3Vector,
1✔
8
  VectorStoreManager,
1✔
9
} from '@storage/protocols/vector'
1✔
10
import { FastifyInstance } from 'fastify'
1✔
11
import fastifyPlugin from 'fastify-plugin'
1✔
12
import { getConfig } from '../../config'
1✔
13

1✔
14
declare module 'fastify' {
1✔
15
  interface FastifyRequest {
1✔
16
    s3Vector: VectorStoreManager
1✔
17
  }
1✔
18
}
1✔
19

1✔
20
const s3VectorClient = createS3VectorClient()
1✔
21
const s3VectorAdapter = new S3Vector(s3VectorClient)
1✔
22

1✔
23
export const s3vector = fastifyPlugin(async function (fastify: FastifyInstance) {
1✔
24
  fastify.addHook('preHandler', async (req) => {
256✔
25
    const { isMultitenant, vectorS3Buckets, vectorMaxBucketsCount, vectorMaxIndexesCount } =
117✔
26
      getConfig()
117✔
27

117✔
28
    if (!vectorS3Buckets || vectorS3Buckets.length === 0) {
117✔
29
      throw ERRORS.FeatureNotEnabled('vector', 'Vector service not configured')
1✔
30
    }
1✔
31

116✔
32
    let maxBucketCount = vectorMaxBucketsCount
116✔
33
    let maxIndexCount = vectorMaxIndexesCount
116✔
34

116✔
35
    if (isMultitenant) {
117!
NEW
36
      const { features } = await getTenantConfig(req.tenantId, { reqId: req.id })
×
37
      maxBucketCount = features?.vectorBuckets?.maxBuckets || vectorMaxBucketsCount
×
38
      maxIndexCount = features?.vectorBuckets?.maxIndexes || vectorMaxIndexesCount
×
39
    }
×
40

116✔
41
    const db = req.db.pool.acquire()
116✔
42
    const store = new KnexVectorMetadataDB(db)
116✔
43
    const shard = isMultitenant
116✔
44
      ? new ShardCatalog(new KnexShardStoreFactory(multitenantKnex))
117!
45
      : new SingleShard({
117✔
46
          shardKey: vectorS3Buckets[0],
116✔
47
          capacity: 10000,
116✔
48
        })
116✔
49

117✔
50
    req.s3Vector = new VectorStoreManager(s3VectorAdapter, store, shard, {
117✔
51
      tenantId: req.tenantId,
117✔
52
      maxBucketCount,
117✔
53
      maxIndexCount,
117✔
54
    })
117✔
55
  })
256✔
56
})
256✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc